public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/98994] New: Empty type with [[no_unique_address]] in union with constructor is not a constant expression
@ 2021-02-08  0:10 david at doublewise dot net
  2021-02-08  9:35 ` [Bug c++/98994] [11 Regression] " rguenth at gcc dot gnu.org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: david at doublewise dot net @ 2021-02-08  0:10 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 98994
           Summary: Empty type with [[no_unique_address]] in union with
                    constructor is not a constant expression
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: david at doublewise dot net
  Target Milestone: ---

The following valid translation unit:

```
struct empty {};

union U {
        constexpr U():
                a()
        {
        }

        [[no_unique_address]] empty a;
};

constexpr U u;
```

is incorrectly rejected by gcc 11 with the error:

```
<source>:12:13: error: 'U()' is not a constant expression
   12 | constexpr U u;
      |             ^
<source>:12:13: error: 'U()' is not a constant expression because it refers to
an incompletely initialized variable
Compiler returned: 1
```

See it live: https://godbolt.org/z/PWcco3

This code was accepted in gcc 10.2.

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

end of thread, other threads:[~2021-02-09 14:35 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-08  0:10 [Bug c++/98994] New: Empty type with [[no_unique_address]] in union with constructor is not a constant expression david at doublewise dot net
2021-02-08  9:35 ` [Bug c++/98994] [11 Regression] " rguenth at gcc dot gnu.org
2021-02-08  9:40 ` [Bug c++/98994] [11 Regression] Empty type with [[no_unique_address]] in union with constructor is not a constant expression since r11-6918 jakub at gcc dot gnu.org
2021-02-08 20:41 ` jason at gcc dot gnu.org
2021-02-09  1:52 ` cvs-commit at gcc dot gnu.org
2021-02-09 14:35 ` jason 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).