Repository navigation
[basic.start.main] Clarify what it means to "use" main CWG2811 #6563
Description
Activity
Alternatively this could adopt the wording for deleted functions in [dcl.fct.def.delete] p2:
A program that refers to a deleted function implicitly or explicitly, other than to declare it, is ill-formed.
@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]?
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.
@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.No, look at the difference between N3154 and N3214. It appears to be intentional.
Reacted by A. JiangYou'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 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.
Is this resolved together with CWG2811?
- 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
The current wording in [basic.start.main] p3 is:
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:
- [basic.def.odr] p8
C++98 Wording
- [basic.start.main] p3
- [basic.def.odr] p2