Non standard return fails to compile

Open
#29 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
45/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
cpp
Domain
backend

Research direction

Search the Boost.Array source for the exact return statement containing BOOST_ASSERT_MSG and elems[i], then inspect its surrounding function. Separate the assertion from the return as described and build the optimized configuration to confirm it compiles; run the relevant Boost.Array tests to verify behavior remains unchanged.

Written by the indexing model from the issue text.

Description

This statement:
return BOOST_ASSERT_MSG( i < N, "out of range" ), elems[i];

is a non-standard form of return.

In case we compile optimized code that lacks assert function but still want something this code fails to compile.

Separating this to a more standard form solves the issue:

BOOST_ASSERT_MSG( i < N, "out of range" );
return elems[i];

Dominant language
C++
Stars
24
Forks
55
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from boostorg/array

All issues in boostorg/array

Similar issues

More C++ issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.