You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[basic.start.main] Clarify what it means to "use" main CWG2811 #6563
The function main shall not be used within a program.
There is no forward reference for what "use" refers to and the word doesn't seem to be defined anywhere, so I'm pretty sure this is meant to mean odr-use:
A function is odr-used if it is named by a potentially-evaluated expression or conversion.
@t3nsor I was initially confused too, but look at the C++98 wording I've edited into the post. In C++98, the paragraph for main literally references use (subsequently renamed to odr-use).
It looks like a purely editorial issue where someone forgot to replace "use" with "odr-use" when the term was renamed.
I don't see any strong reason why the renaming of "use" to "odr-use" should suddenly change the restrictions on main. That would be surprising and I don't think it is CWG intent.
You're probably right, but then what does "use" even mean? It used to have a definition but now it's pretty meaningless. There should at least be a note which clarifies what constitutes "use" of main.
That's the problem: I don't think anyone knows for sure what it means, so this should go to CWG. Especially since the language has evolved so much that there may be new questions to consider that may not have existed in C++11.
I'm pretty sure CWG left "use" in there because it wasn't clearly "odr-use" that was intended here, but the paper to introduce "odr-use" was important enough not to get hung up over it.
We need answers for decltype(::main) as well as sizeof(&::main), for example. It's plausible that forming even an unevaluated pointer-to-main is hard to support on some platforms (because it might have a type that is not representable in C++).
Going the "deleted function" route sounds promising.
changed the title [-][basic.start.main] Clarify what it means to "use" `main`[/-][+][basic.start.main] Clarify what it means to "use" `main` CWG2811[/+]on Aug 7, 2024
Activity
eisenwave commentedon Sep 12, 2023
Alternatively this could adopt the wording for deleted functions in [dcl.fct.def.delete] p2:
eisenwave commentedon Sep 12, 2023
@jensmaurer your paper replaced "use ([basic.def.odr])" with "use".
Why is odr-use not the right interpretation here, and what is?
C++98 used to define use. Did you make a typo and you meant to replace "use" with "odr-use" instead of just removing the reference to [basic.def.odr]?
t3nsor commentedon Sep 12, 2023
Frustratingly, I can't find anything in the meeting minutes about why this change was made between N3154 and N3214. See https://stackoverflow.com/a/25298934/481267
I don't think it's editorial. I think CWG should try to come to an agreement about what it's supposed to mean.
eisenwave commentedon Sep 12, 2023
@t3nsor I was initially confused too, but look at the C++98 wording I've edited into the post. In C++98, the paragraph for
mainliterally references use (subsequently renamed to odr-use).It looks like a purely editorial issue where someone forgot to replace "use" with "odr-use" when the term was renamed.
I don't see any strong reason why the renaming of "use" to "odr-use" should suddenly change the restrictions on
main. That would be surprising and I don't think it is CWG intent.t3nsor commentedon Sep 12, 2023
No, look at the difference between N3154 and N3214. It appears to be intentional.
eisenwave commentedon Sep 12, 2023
You're probably right, but then what does "use" even mean? It used to have a definition but now it's pretty meaningless. There should at least be a note which clarifies what constitutes "use" of
main.t3nsor commentedon Sep 12, 2023
That's the problem: I don't think anyone knows for sure what it means, so this should go to CWG. Especially since the language has evolved so much that there may be new questions to consider that may not have existed in C++11.
jensmaurer commentedon Sep 21, 2023
I'm pretty sure CWG left "use" in there because it wasn't clearly "odr-use" that was intended here, but the paper to introduce "odr-use" was important enough not to get hung up over it.
We need answers for
decltype(::main)as well assizeof(&::main), for example. It's plausible that forming even an unevaluated pointer-to-main is hard to support on some platforms (because it might have a type that is not representable in C++).Going the "deleted function" route sounds promising.
frederick-vs-ja commentedon Aug 7, 2024
Is this resolved together with CWG2811?
[-][basic.start.main] Clarify what it means to "use" `main`[/-][+][basic.start.main] Clarify what it means to "use" `main` CWG2811[/+]