-
Notifications
You must be signed in to change notification settings - Fork 8
Description
Reference (section label): [basic.start.main] p3
Short Issue Description
In [basic.start.main] paragraph 3, it is unclear what "use" of the function main means.
Long Issue description
The accepted proposal N3214 by @jensmaurer made the following change:
Replace all occurrences of the word "use" that are not intended as references to 3.2 with some other term, such as "occurrence" or "appearance" or "reference to".
However, this resolution was not correctly applied to [basic.start.main] p3:
The function main shall not be used
-(3.2 basic.def.odr)
within a program.This change violates the proposed resolution but might be deliberate, not accidental, because the first revision of N3154 did replace "use" with "odr-use", and this was later reverted.
It remains unclear what constitutes "use" of main and implementers seemingly disagree. Only Clang considers decltype(main) to constitute use of main (https://godbolt.org/z/6MPWfPzYK) and issues a warning:
<source>:2:24: warning: ISO C++ does not allow 'main' to be used by a program [-Wmain]
2 | using T = decltype(main);
|
It is possible that the change between revisions is accidental, not deliberate. In any case, disallowing decltype(main) is an arbitrary restriction and solves no implementation challenges. Disallowing only odr-use of main seems adequate, and matches the original C++98 restrictions exactly.
Suggested Resolution
Change [basic.start.main] p3 as follows:
The function main shall not be
-used
+odr-used
within the program.