public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/109795] New: is_standard_layout incorrect for colliding member and base class
@ 2023-05-09 23:23 myriachan at gmail dot com
  2023-05-09 23:28 ` [Bug c++/109795] " pinskia at gcc dot gnu.org
  0 siblings, 1 reply; 2+ messages in thread
From: myriachan at gmail dot com @ 2023-05-09 23:23 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109795

            Bug ID: 109795
           Summary: is_standard_layout incorrect for colliding member and
                    base class
           Product: gcc
           Version: 13.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: myriachan at gmail dot com
  Target Milestone: ---

The following compiles on GCC 13.1.0 when it should not:

struct X { };
struct Y {
    X x;
};
struct Z : X {
    Y y;
};
static_assert(!__is_standard_layout(Z));

By [class.prop]/3.7, rule 3.7.2 makes M(Z) = { Y } union M(Y).  Applying 3.7.2
recursively results in M(Y) = { X } union M(X).  By rule 3.7.1, M(X) = { }.  So
M(Z) = { Y, X }.  By rule 3.7, Z is not standard-layout, because Z's base class
X is an element of M(Z) = { Y, X }.

https://gcc.godbolt.org/z/oWhc8vs6z

^ permalink raw reply	[flat|nested] 2+ messages in thread

* [Bug c++/109795] is_standard_layout incorrect for colliding member and base class
  2023-05-09 23:23 [Bug c++/109795] New: is_standard_layout incorrect for colliding member and base class myriachan at gmail dot com
@ 2023-05-09 23:28 ` pinskia at gcc dot gnu.org
  0 siblings, 0 replies; 2+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-05-09 23:28 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109795

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
>The following compiles on GCC 13.1.0 when it should not:

You have the opposite way around. GCC is the one which rejects this code while
the other compilers accept it ...

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-05-09 23:28 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-09 23:23 [Bug c++/109795] New: is_standard_layout incorrect for colliding member and base class myriachan at gmail dot com
2023-05-09 23:28 ` [Bug c++/109795] " pinskia 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).