Created on 2014-10-06.00:00:00 last changed 94 months ago
Proposed resolution (October, 2015):
Change 6.9.3.1 [basic.start.main] paragraph 5 as follows:
A return statement in main has the effect of leaving the main function (destroying any objects with automatic storage duration) and calling std::exit with the return value as the argument. If control
reachesflows off the end of the compound-statement of mainwithout encountering a return statement, the effect isthat of executingequivalent to a return with operand 0 (see also 14.4 [except.handle]).return 0;
Change 8.7.4 [stmt.return] paragraph 2 as follows:
...Flowing off the end of a function with a void return type is equivalent to a return with novalue; this results in undefined behavior in a value-returning functionoperand. Otherwise, flowing off the end of a function other than main (6.9.3.1 [basic.start.main] results in undefined behavior.
Change 14.4 [except.handle] paragraph 14 as follows:
The currently handled exception is rethrown if control reaches the end of a handler of the function-try-block of a constructor or destructor. Otherwise,a function returns when control reaches the end of a handler for the function-try-block (8.7.4 [stmt.return]). Flowing off the end of a function-try-block is equivalent to a return with no value; this results in undefined behavior in a value-returning function (8.7.4 [stmt.return])flowing off the end of the compound-statement of a handler of a function-try-block is equivalent to flowing off the end of the compound-statement of that function (see 8.7.4 [stmt.return]).
Additional notes, October, 2015:
There is similar wording in 14.4 [except.handle] paragraph 14. Also, it might be better to avoid the use of the word “value”, since it is currently not clearly defined.
Proposed resolution (May, 2015): [SUPERSEDED]
Change 8.7.4 [stmt.return] paragraph 2 as follows:
...Flowing off the end of a value-returning function is undefined behavior. Flowing off the end of any other function is equivalent to a return with no value; this results in undefined behavior in a value-returning function.
[Adopted at the February, 2016 meeting.]
According to 8.7.4 [stmt.return] paragraph 2,
Flowing off the end of a function is equivalent to a return with no value...
This is not correct, since a return with no value is ill-formed in a value-returning function but flowing off the end results in undefined behavior.
History | |||
---|---|---|---|
Date | User | Action | Args |
2017-02-06 00:00:00 | admin | set | status: ready -> cd4 |
2015-11-10 00:00:00 | admin | set | messages: + msg5574 |
2015-11-10 00:00:00 | admin | set | messages: + msg5573 |
2015-05-25 00:00:00 | admin | set | messages: + msg5452 |
2015-05-25 00:00:00 | admin | set | status: drafting -> ready |
2014-10-06 00:00:00 | admin | create |