public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/101767] New: Aggregate initialization fails for struct that has both unnamed struct and union fields
@ 2021-08-03 20:18 xtkoba at gmail dot com
  2021-08-03 20:40 ` [Bug c++/101767] [11/12 Regression] " pinskia at gcc dot gnu.org
                   ` (12 more replies)
  0 siblings, 13 replies; 14+ messages in thread
From: xtkoba at gmail dot com @ 2021-08-03 20:18 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 101767
           Summary: Aggregate initialization fails for struct that has
                    both unnamed struct and union fields
           Product: gcc
           Version: 11.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: xtkoba at gmail dot com
  Target Milestone: ---

Created attachment 51254
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=51254&action=edit
Repro

$ cat unnamed_fields.cc

typedef struct {
  struct {
    int x;
  };
  union {
    int y;
    float z;
  };
} S;

void foo(void)
{
  [[maybe_unused]] S a = {
    .x = 1,
    .y = 0
  };
}

$ g++-11.2.0 unnamed_fields.cc -c
unnamed_fields.cc: In function 'void foo()':
unnamed_fields.cc:17:3: error: 'S::<unnamed struct>' has no non-static data
member named 'y'
   17 |   };
      |   ^

$ g++-11.2.0 -v
Using built-in specs.
COLLECT_GCC=g++-11.2.0
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-pc-linux-gnu/11.2.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with:
/var/tmp/portage/sys-devel/gcc-11.2.0/work/gcc-11.2.0/configure
--host=x86_64-pc-linux-gnu --build=x86_64-pc-linux-gnu --prefix=/usr
--bindir=/usr/x86_64-pc-linux-gnu/gcc-bin/11.2.0
--includedir=/usr/lib/gcc/x86_64-pc-linux-gnu/11.2.0/include
--datadir=/usr/share/gcc-data/x86_64-pc-linux-gnu/11.2.0
--mandir=/usr/share/gcc-data/x86_64-pc-linux-gnu/11.2.0/man
--infodir=/usr/share/gcc-data/x86_64-pc-linux-gnu/11.2.0/info
--with-gxx-include-dir=/usr/lib/gcc/x86_64-pc-linux-gnu/11.2.0/include/g++-v11
--with-python-dir=/share/gcc-data/x86_64-pc-linux-gnu/11.2.0/python
--enable-languages=c,c++,fortran --enable-obsolete --enable-secureplt
--disable-werror --with-system-zlib --enable-nls --without-included-gettext
--disable-libunwind-exceptions --enable-checking=release
--with-bugurl=https://bugs.gentoo.org/ --with-pkgversion='Gentoo 11.2.0 p1'
--disable-esp --enable-libstdcxx-time --enable-shared --enable-threads=posix
--enable-__cxa_atexit --enable-clocale=gnu --enable-multilib
--with-multilib-list=m32,m64 --disable-fixed-point --enable-targets=all
--enable-libgomp --disable-libssp --disable-libada --disable-systemtap
--disable-valgrind-annotations --disable-vtable-verify --disable-libvtv
--without-zstd --enable-lto --without-isl --enable-default-pie
--enable-default-ssp
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 11.2.0 (Gentoo 11.2.0 p1)

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

* [Bug c++/101767] [11/12 Regression] Aggregate initialization fails for struct that has both unnamed struct and union fields
  2021-08-03 20:18 [Bug c++/101767] New: Aggregate initialization fails for struct that has both unnamed struct and union fields xtkoba at gmail dot com
@ 2021-08-03 20:40 ` pinskia at gcc dot gnu.org
  2021-08-03 20:50 ` [Bug c++/101767] [10/11/12 " pinskia at gcc dot gnu.org
                   ` (11 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-08-03 20:40 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |11.3

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

* [Bug c++/101767] [10/11/12 Regression] Aggregate initialization fails for struct that has both unnamed struct and union fields
  2021-08-03 20:18 [Bug c++/101767] New: Aggregate initialization fails for struct that has both unnamed struct and union fields xtkoba at gmail dot com
  2021-08-03 20:40 ` [Bug c++/101767] [11/12 Regression] " pinskia at gcc dot gnu.org
@ 2021-08-03 20:50 ` pinskia at gcc dot gnu.org
  2021-08-04  5:59 ` rguenth at gcc dot gnu.org
                   ` (10 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-08-03 20:50 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|[11/12 Regression]          |[10/11/12 Regression]
                   |Aggregate initialization    |Aggregate initialization
                   |fails for struct that has   |fails for struct that has
                   |both unnamed struct and     |both unnamed struct and
                   |union fields                |union fields
   Target Milestone|11.3                        |10.4
           See Also|                            |https://gcc.gnu.org/bugzill
                   |                            |a/show_bug.cgi?id=100489
     Ever confirmed|0                           |1
             Status|UNCONFIRMED                 |NEW
      Known to work|                            |10.3.0
   Last reconfirmed|                            |2021-08-03

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
So this is most likely caused by the patch which fixes PR 100489 so this is a
regression in 10.4.0 also.

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

* [Bug c++/101767] [10/11/12 Regression] Aggregate initialization fails for struct that has both unnamed struct and union fields
  2021-08-03 20:18 [Bug c++/101767] New: Aggregate initialization fails for struct that has both unnamed struct and union fields xtkoba at gmail dot com
  2021-08-03 20:40 ` [Bug c++/101767] [11/12 Regression] " pinskia at gcc dot gnu.org
  2021-08-03 20:50 ` [Bug c++/101767] [10/11/12 " pinskia at gcc dot gnu.org
@ 2021-08-04  5:59 ` rguenth at gcc dot gnu.org
  2021-11-16 21:56 ` pinskia at gcc dot gnu.org
                   ` (9 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-08-04  5:59 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P3                          |P2

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

* [Bug c++/101767] [10/11/12 Regression] Aggregate initialization fails for struct that has both unnamed struct and union fields
  2021-08-03 20:18 [Bug c++/101767] New: Aggregate initialization fails for struct that has both unnamed struct and union fields xtkoba at gmail dot com
                   ` (2 preceding siblings ...)
  2021-08-04  5:59 ` rguenth at gcc dot gnu.org
@ 2021-11-16 21:56 ` pinskia at gcc dot gnu.org
  2022-01-20 14:52 ` ppalka at gcc dot gnu.org
                   ` (8 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-11-16 21:56 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |roland at gnu dot org

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
*** Bug 103290 has been marked as a duplicate of this bug. ***

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

* [Bug c++/101767] [10/11/12 Regression] Aggregate initialization fails for struct that has both unnamed struct and union fields
  2021-08-03 20:18 [Bug c++/101767] New: Aggregate initialization fails for struct that has both unnamed struct and union fields xtkoba at gmail dot com
                   ` (3 preceding siblings ...)
  2021-11-16 21:56 ` pinskia at gcc dot gnu.org
@ 2022-01-20 14:52 ` ppalka at gcc dot gnu.org
  2022-02-09  8:23 ` antmak.pub at gmail dot com
                   ` (7 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: ppalka at gcc dot gnu.org @ 2022-01-20 14:52 UTC (permalink / raw)
  To: gcc-bugs

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

Patrick Palka <ppalka at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ppalka at gcc dot gnu.org

--- Comment #3 from Patrick Palka <ppalka at gcc dot gnu.org> ---
(In reply to Andrew Pinski from comment #1)
> So this is most likely caused by the patch which fixes PR 100489 so this is
> a regression in 10.4.0 also.

Yep, started with r12-954.

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

* [Bug c++/101767] [10/11/12 Regression] Aggregate initialization fails for struct that has both unnamed struct and union fields
  2021-08-03 20:18 [Bug c++/101767] New: Aggregate initialization fails for struct that has both unnamed struct and union fields xtkoba at gmail dot com
                   ` (4 preceding siblings ...)
  2022-01-20 14:52 ` ppalka at gcc dot gnu.org
@ 2022-02-09  8:23 ` antmak.pub at gmail dot com
  2022-03-18 18:12 ` jason at gcc dot gnu.org
                   ` (6 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: antmak.pub at gmail dot com @ 2022-02-09  8:23 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Anton Maklakov <antmak.pub at gmail dot com> ---
I've stumbled this bug as well

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

* [Bug c++/101767] [10/11/12 Regression] Aggregate initialization fails for struct that has both unnamed struct and union fields
  2021-08-03 20:18 [Bug c++/101767] New: Aggregate initialization fails for struct that has both unnamed struct and union fields xtkoba at gmail dot com
                   ` (5 preceding siblings ...)
  2022-02-09  8:23 ` antmak.pub at gmail dot com
@ 2022-03-18 18:12 ` jason at gcc dot gnu.org
  2022-03-21 20:47 ` cvs-commit at gcc dot gnu.org
                   ` (5 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: jason at gcc dot gnu.org @ 2022-03-18 18:12 UTC (permalink / raw)
  To: gcc-bugs

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

Jason Merrill <jason at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
           Assignee|unassigned at gcc dot gnu.org      |jason at gcc dot gnu.org
                 CC|                            |jason at gcc dot gnu.org

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

* [Bug c++/101767] [10/11/12 Regression] Aggregate initialization fails for struct that has both unnamed struct and union fields
  2021-08-03 20:18 [Bug c++/101767] New: Aggregate initialization fails for struct that has both unnamed struct and union fields xtkoba at gmail dot com
                   ` (6 preceding siblings ...)
  2022-03-18 18:12 ` jason at gcc dot gnu.org
@ 2022-03-21 20:47 ` cvs-commit at gcc dot gnu.org
  2022-03-21 20:58 ` [Bug c++/101767] [11 " jason at gcc dot gnu.org
                   ` (4 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-03-21 20:47 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jason Merrill <jason@gcc.gnu.org>:

https://gcc.gnu.org/g:e3e191b4104c7d6a177f66dbb77cabf05ab63781

commit r12-7740-ge3e191b4104c7d6a177f66dbb77cabf05ab63781
Author: Jason Merrill <jason@redhat.com>
Date:   Fri Mar 18 14:36:19 2022 -0400

    c++: designator and anon struct [PR101767]

    We found .x in the anonymous struct, but then didn't find .y there; we
    should decide that means we're done with the struct rather than that the
    code is wrong.

            PR c++/101767

    gcc/cp/ChangeLog:

            * decl.cc (reshape_init_class): Back out of anon struct
            if a designator doesn't match.

    gcc/testsuite/ChangeLog:

            * g++.dg/ext/anon-struct10.C: New test.

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

* [Bug c++/101767] [11 Regression] Aggregate initialization fails for struct that has both unnamed struct and union fields
  2021-08-03 20:18 [Bug c++/101767] New: Aggregate initialization fails for struct that has both unnamed struct and union fields xtkoba at gmail dot com
                   ` (7 preceding siblings ...)
  2022-03-21 20:47 ` cvs-commit at gcc dot gnu.org
@ 2022-03-21 20:58 ` jason at gcc dot gnu.org
  2022-03-22  5:18 ` cvs-commit at gcc dot gnu.org
                   ` (3 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: jason at gcc dot gnu.org @ 2022-03-21 20:58 UTC (permalink / raw)
  To: gcc-bugs

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

Jason Merrill <jason at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|[10/11/12 Regression]       |[11 Regression] Aggregate
                   |Aggregate initialization    |initialization fails for
                   |fails for struct that has   |struct that has both
                   |both unnamed struct and     |unnamed struct and union
                   |union fields                |fields
   Target Milestone|10.4                        |11.3
           Priority|P2                          |P1
      Known to work|                            |12.0

--- Comment #6 from Jason Merrill <jason at gcc dot gnu.org> ---
The 10 branch patch was just removing an assert, so it didn't regress there.

Fixed on trunk so far.  Marking P1 for 11 branch.

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

* [Bug c++/101767] [11 Regression] Aggregate initialization fails for struct that has both unnamed struct and union fields
  2021-08-03 20:18 [Bug c++/101767] New: Aggregate initialization fails for struct that has both unnamed struct and union fields xtkoba at gmail dot com
                   ` (8 preceding siblings ...)
  2022-03-21 20:58 ` [Bug c++/101767] [11 " jason at gcc dot gnu.org
@ 2022-03-22  5:18 ` cvs-commit at gcc dot gnu.org
  2022-03-26 23:29 ` jason at gcc dot gnu.org
                   ` (2 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-03-22  5:18 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #7 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-11 branch has been updated by Jason Merrill
<jason@gcc.gnu.org>:

https://gcc.gnu.org/g:b94c95fc1199bfa2c7ab577921b07ef545976cac

commit r11-9677-gb94c95fc1199bfa2c7ab577921b07ef545976cac
Author: Jason Merrill <jason@redhat.com>
Date:   Fri Mar 18 14:36:19 2022 -0400

    c++: designator and anon struct [PR101767]

    We found .x in the anonymous struct, but then didn't find .y there; we
    should decide that means we're done with the struct rather than that the
    code is wrong.

            PR c++/101767

    gcc/cp/ChangeLog:

            * decl.c (reshape_init_class): Back out of anon struct
            if a designator doesn't match.

    gcc/testsuite/ChangeLog:

            * g++.dg/ext/anon-struct10.C: New test.

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

* [Bug c++/101767] [11 Regression] Aggregate initialization fails for struct that has both unnamed struct and union fields
  2021-08-03 20:18 [Bug c++/101767] New: Aggregate initialization fails for struct that has both unnamed struct and union fields xtkoba at gmail dot com
                   ` (9 preceding siblings ...)
  2022-03-22  5:18 ` cvs-commit at gcc dot gnu.org
@ 2022-03-26 23:29 ` jason at gcc dot gnu.org
  2022-05-12 21:14 ` cvs-commit at gcc dot gnu.org
  2022-05-12 22:24 ` cvs-commit at gcc dot gnu.org
  12 siblings, 0 replies; 14+ messages in thread
From: jason at gcc dot gnu.org @ 2022-03-26 23:29 UTC (permalink / raw)
  To: gcc-bugs

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

Jason Merrill <jason at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
             Status|ASSIGNED                    |RESOLVED

--- Comment #8 from Jason Merrill <jason at gcc dot gnu.org> ---
Fixed for 11.3

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

* [Bug c++/101767] [11 Regression] Aggregate initialization fails for struct that has both unnamed struct and union fields
  2021-08-03 20:18 [Bug c++/101767] New: Aggregate initialization fails for struct that has both unnamed struct and union fields xtkoba at gmail dot com
                   ` (10 preceding siblings ...)
  2022-03-26 23:29 ` jason at gcc dot gnu.org
@ 2022-05-12 21:14 ` cvs-commit at gcc dot gnu.org
  2022-05-12 22:24 ` cvs-commit at gcc dot gnu.org
  12 siblings, 0 replies; 14+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-05-12 21:14 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #9 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-10 branch has been updated by Jason Merrill
<jason@gcc.gnu.org>:

https://gcc.gnu.org/g:846bff4d4659d9b2026da574194599f38a00cc79

commit r10-10718-g846bff4d4659d9b2026da574194599f38a00cc79
Author: Jason Merrill <jason@redhat.com>
Date:   Fri Mar 18 14:36:19 2022 -0400

    c++: designator and anon struct [PR101767]

    We found .x in the anonymous struct, but then didn't find .y there; we
    should decide that means we're done with the struct rather than that the
    code is wrong.

            PR c++/101767

    gcc/cp/ChangeLog:

            * decl.c (reshape_init_class): Back out of anon struct
            if a designator doesn't match.

    gcc/testsuite/ChangeLog:

            * g++.dg/ext/anon-struct10.C: New test.

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

* [Bug c++/101767] [11 Regression] Aggregate initialization fails for struct that has both unnamed struct and union fields
  2021-08-03 20:18 [Bug c++/101767] New: Aggregate initialization fails for struct that has both unnamed struct and union fields xtkoba at gmail dot com
                   ` (11 preceding siblings ...)
  2022-05-12 21:14 ` cvs-commit at gcc dot gnu.org
@ 2022-05-12 22:24 ` cvs-commit at gcc dot gnu.org
  12 siblings, 0 replies; 14+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-05-12 22:24 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #10 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-10 branch has been updated by Jason Merrill
<jason@gcc.gnu.org>:

https://gcc.gnu.org/g:0807111e6347778910c9cf63521b7c838effceb8

commit r10-10731-g0807111e6347778910c9cf63521b7c838effceb8
Author: Jason Merrill <jason@redhat.com>
Date:   Thu May 12 17:38:40 2022 -0400

    Revert "c++: designator and anon struct [PR101767]"

    101767 wasn't broken on the 10 branch, so it doesn't need the fix, just the
    test.

            PR c++/101767

    This reverts commit 846bff4d4659d9b2026da574194599f38a00cc79.

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

end of thread, other threads:[~2022-05-12 22:24 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-03 20:18 [Bug c++/101767] New: Aggregate initialization fails for struct that has both unnamed struct and union fields xtkoba at gmail dot com
2021-08-03 20:40 ` [Bug c++/101767] [11/12 Regression] " pinskia at gcc dot gnu.org
2021-08-03 20:50 ` [Bug c++/101767] [10/11/12 " pinskia at gcc dot gnu.org
2021-08-04  5:59 ` rguenth at gcc dot gnu.org
2021-11-16 21:56 ` pinskia at gcc dot gnu.org
2022-01-20 14:52 ` ppalka at gcc dot gnu.org
2022-02-09  8:23 ` antmak.pub at gmail dot com
2022-03-18 18:12 ` jason at gcc dot gnu.org
2022-03-21 20:47 ` cvs-commit at gcc dot gnu.org
2022-03-21 20:58 ` [Bug c++/101767] [11 " jason at gcc dot gnu.org
2022-03-22  5:18 ` cvs-commit at gcc dot gnu.org
2022-03-26 23:29 ` jason at gcc dot gnu.org
2022-05-12 21:14 ` cvs-commit at gcc dot gnu.org
2022-05-12 22:24 ` cvs-commit 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).