[Bug c++/107126] GCC accepts invalid out of class definition for destructor with C++17
redi at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Mon Oct 3 09:51:31 GMT 2022
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107126
--- Comment #7 from Jonathan Wakely <redi at gcc dot gnu.org> ---
https://wg21.link/cwg1435 introduced the wording that allows this (which can
still be seen in the context for the [class.dtor] changes in CWG 2337):
"in a declaration at namespace scope or in a friend declaration, the
id-expression is nested-name-specifier ~class-name and the class-name names the
same class as the nested-name-specifier."
https://wg21.link/p1787r6 changed that to:
"otherwise, the id-expression is nested-name-specifier ~class-name and the
class-name is the injected-class-name of the class nominated by the
nested-name-specifier."
This seems like a breaking change that was not obvious from the revision
history of the r5 paper:
- Required destructor declarations to use the injected-class-name, avoiding
name lookup
- Simplified lookup for destructors
- Specified that < begins a template argument list in a destructor name
All compilers accept the program in C++17 mode, and I don't think it's at all
clear that the code was always invalid in older standards, as you claim.
More information about the Gcc-bugs
mailing list