public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/109739] New: bogus warning due to -Wmissing-field-initializers in C++20 with designated initializers on struct with empty base class
@ 2023-05-04 15:59 tobias.rittweiler at contractors dot roche.com
  2023-06-08 13:01 ` [Bug c++/109739] " mpolacek at gcc dot gnu.org
  2024-06-17  9:29 ` mkretz at gcc dot gnu.org
  0 siblings, 2 replies; 3+ messages in thread
From: tobias.rittweiler at contractors dot roche.com @ 2023-05-04 15:59 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 109739
           Summary: bogus warning due to -Wmissing-field-initializers in
                    C++20 with designated initializers on struct with
                    empty base class
           Product: gcc
           Version: 13.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: tobias.rittweiler at contractors dot roche.com
  Target Milestone: ---

<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
#include <cstdint>

struct Empty {};

struct S : Empty {
    uint32_t Uint32;
};

void consume(const S&) {}

void test() {
    S s = { .Uint32 = 42 };
    consume(s);
}
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

gcc-13.1 -std=c++20 -Werror=missing-field-initializers

<source>: In function 'void test()':
<source>:12:26: error: missing initializer for member 'S::<anonymous>'
[-Werror=missing-field-initializers]
   12 |     S s = { .Uint32 = 42 };
      |                          ^
cc1plus: some warnings being treated as errors
Compiler returned: 1


My reading of
https://en.cppreference.com/w/cpp/language/aggregate_initialization is that
since C++17 base classes are allowed in class type to form an "aggregate" and
designated initializers are allowed since C++20.

So I would expect this example to be free of any warning.


(I am aware of the situation that the man page currently says that
`-Wmissing-field-initializers` "does not warn about designated initializers"
but that is evidently not true in the C++ frontend, as has been pointed out
before, see [1], [2].)


[1] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=39589#c11
[2] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96868#c3

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

* [Bug c++/109739] bogus warning due to -Wmissing-field-initializers in C++20 with designated initializers on struct with empty base class
  2023-05-04 15:59 [Bug c++/109739] New: bogus warning due to -Wmissing-field-initializers in C++20 with designated initializers on struct with empty base class tobias.rittweiler at contractors dot roche.com
@ 2023-06-08 13:01 ` mpolacek at gcc dot gnu.org
  2024-06-17  9:29 ` mkretz at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2023-06-08 13:01 UTC (permalink / raw)
  To: gcc-bugs

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

Marek Polacek <mpolacek at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |mpolacek at gcc dot gnu.org
           See Also|                            |https://gcc.gnu.org/bugzill
                   |                            |a/show_bug.cgi?id=110064

--- Comment #1 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Looks like a dup of bug 110064.

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

* [Bug c++/109739] bogus warning due to -Wmissing-field-initializers in C++20 with designated initializers on struct with empty base class
  2023-05-04 15:59 [Bug c++/109739] New: bogus warning due to -Wmissing-field-initializers in C++20 with designated initializers on struct with empty base class tobias.rittweiler at contractors dot roche.com
  2023-06-08 13:01 ` [Bug c++/109739] " mpolacek at gcc dot gnu.org
@ 2024-06-17  9:29 ` mkretz at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: mkretz at gcc dot gnu.org @ 2024-06-17  9:29 UTC (permalink / raw)
  To: gcc-bugs

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

Matthias Kretz (Vir) <mkretz at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |mkretz at gcc dot gnu.org
         Resolution|---                         |FIXED
             Status|UNCONFIRMED                 |RESOLVED

--- Comment #2 from Matthias Kretz (Vir) <mkretz at gcc dot gnu.org> ---
This was fixed in GCC 14 via 110064.

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

end of thread, other threads:[~2024-06-17  9:29 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-04 15:59 [Bug c++/109739] New: bogus warning due to -Wmissing-field-initializers in C++20 with designated initializers on struct with empty base class tobias.rittweiler at contractors dot roche.com
2023-06-08 13:01 ` [Bug c++/109739] " mpolacek at gcc dot gnu.org
2024-06-17  9:29 ` mkretz 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).