public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
* [Bug c++/102201] New: Accepts invalid C++98 with nested class and sizeof of outer's non-static field @ 2021-09-04 14:07 pinskia at gcc dot gnu.org 2021-09-04 17:01 ` [Bug c++/102201] " harald at gigawatt dot nl ` (3 more replies) 0 siblings, 4 replies; 5+ messages in thread From: pinskia at gcc dot gnu.org @ 2021-09-04 14:07 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102201 Bug ID: 102201 Summary: Accepts invalid C++98 with nested class and sizeof of outer's non-static field Product: gcc Version: 12.0 Status: UNCONFIRMED Keywords: accepts-invalid Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: pinskia at gcc dot gnu.org Target Milestone: --- Take: struct outer { struct inner { inner() :x(sizeof(y)) { } unsigned int x; }; int y; }; ----- CUT ---- The above code is valid C++11 but invalid C++98 because the field y is non-static. ^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/102201] Accepts invalid C++98 with nested class and sizeof of outer's non-static field 2021-09-04 14:07 [Bug c++/102201] New: Accepts invalid C++98 with nested class and sizeof of outer's non-static field pinskia at gcc dot gnu.org @ 2021-09-04 17:01 ` harald at gigawatt dot nl 2021-09-06 16:03 ` redi at gcc dot gnu.org ` (2 subsequent siblings) 3 siblings, 0 replies; 5+ messages in thread From: harald at gigawatt dot nl @ 2021-09-04 17:01 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102201 Harald van Dijk <harald at gigawatt dot nl> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |harald at gigawatt dot nl --- Comment #1 from Harald van Dijk <harald at gigawatt dot nl> --- This doesn't need inner classes, a simpler reproducer is: struct S { int i; }; int j = sizeof S::i; gcc accepts this in all modes ever since the C++11 rule for non-static members in unevaluated contexts was implemented (4.4). clang says in C++98 mode: test.cc:2:19: error: invalid use of non-static data member 'i' int j = sizeof S::i; ~~~^ 1 error generated. ^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/102201] Accepts invalid C++98 with nested class and sizeof of outer's non-static field 2021-09-04 14:07 [Bug c++/102201] New: Accepts invalid C++98 with nested class and sizeof of outer's non-static field pinskia at gcc dot gnu.org 2021-09-04 17:01 ` [Bug c++/102201] " harald at gigawatt dot nl @ 2021-09-06 16:03 ` redi at gcc dot gnu.org 2021-09-06 18:42 ` pinskia at gcc dot gnu.org 2021-09-08 8:20 ` redi at gcc dot gnu.org 3 siblings, 0 replies; 5+ messages in thread From: redi at gcc dot gnu.org @ 2021-09-06 16:03 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102201 Jonathan Wakely <redi at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jason at gcc dot gnu.org --- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> --- It's accepted since: C++ DR 613 C++ DR 613 * semantics.c (finish_non_static_data_member): Allow such references without an associated object in sizeof/decltype/alignof. From-SVN: r145375 (and SVN r145620 on the gcc-4.4 branch). Presumably treating it as a DR was intentional. ^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/102201] Accepts invalid C++98 with nested class and sizeof of outer's non-static field 2021-09-04 14:07 [Bug c++/102201] New: Accepts invalid C++98 with nested class and sizeof of outer's non-static field pinskia at gcc dot gnu.org 2021-09-04 17:01 ` [Bug c++/102201] " harald at gigawatt dot nl 2021-09-06 16:03 ` redi at gcc dot gnu.org @ 2021-09-06 18:42 ` pinskia at gcc dot gnu.org 2021-09-08 8:20 ` redi at gcc dot gnu.org 3 siblings, 0 replies; 5+ messages in thread From: pinskia at gcc dot gnu.org @ 2021-09-06 18:42 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102201 Andrew Pinski <pinskia at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Resolution|--- |WONTFIX Status|UNCONFIRMED |RESOLVED --- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> --- DR613 is CD1 so yes it is included in C++98/C++03. clang must have decided CD1's are not included ... ^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/102201] Accepts invalid C++98 with nested class and sizeof of outer's non-static field 2021-09-04 14:07 [Bug c++/102201] New: Accepts invalid C++98 with nested class and sizeof of outer's non-static field pinskia at gcc dot gnu.org ` (2 preceding siblings ...) 2021-09-06 18:42 ` pinskia at gcc dot gnu.org @ 2021-09-08 8:20 ` redi at gcc dot gnu.org 3 siblings, 0 replies; 5+ messages in thread From: redi at gcc dot gnu.org @ 2021-09-08 8:20 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102201 --- Comment #4 from Jonathan Wakely <redi at gcc dot gnu.org> --- CD1 was a C++0x draft: "CD1: A DR issue not resolved in TC1 but included in Committee Draft 1. CD1 was advanced for balloting at the September, 2008 WG21 meeting." DR 613 was resolved by N2253, which was a post-C++03 change, and wasn't adopted as a defect report. So arguably Clang is right to reject it in C++03 mode. We could make it a pedwarn, but I think WONTFIX is probably right. There seems to be no advantage to rejecting it (strictly conforming C++98 programs aren't going to be using SFINAE tricks that could detect this). ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2021-09-08 8:20 UTC | newest] Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2021-09-04 14:07 [Bug c++/102201] New: Accepts invalid C++98 with nested class and sizeof of outer's non-static field pinskia at gcc dot gnu.org 2021-09-04 17:01 ` [Bug c++/102201] " harald at gigawatt dot nl 2021-09-06 16:03 ` redi at gcc dot gnu.org 2021-09-06 18:42 ` pinskia at gcc dot gnu.org 2021-09-08 8:20 ` redi at gcc dot gnu.org
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).