public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "de34 at live dot cn" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/112439] New: Modification of a member overlapping with a [[no_unique_address]] member in the constructor is incorrectly rejected
Date: Wed, 08 Nov 2023 11:33:36 +0000	[thread overview]
Message-ID: <bug-112439-4@http.gcc.gnu.org/bugzilla/> (raw)

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

            Bug ID: 112439
           Summary: Modification of a member overlapping with a
                    [[no_unique_address]] member in the constructor is
                    incorrectly rejected
           Product: gcc
           Version: 13.2.1
            Status: UNCONFIRMED
          Keywords: rejects-valid
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: de34 at live dot cn
  Target Milestone: ---

GCC starts (incorrectly) rejecting the following code snipped since GCC13
(https://godbolt.org/z/faqMahz34). It's wrong to emit an error for this because
c is not const in the constructor body.

```
struct Empty {};

class Foo {
public:
    constexpr Foo(int x, Empty y, int z) : a(x), b(y)
    {
        c = z;
    }

private:
    int a{};
    [[no_unique_address]] Empty b{};
    [[no_unique_address]] int c{};
};

constexpr Foo r{1, {}, 3};
```

It seems that the code is correctly accepted if b and c are made not to
overlap.

             reply	other threads:[~2023-11-08 11:33 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-08 11:33 de34 at live dot cn [this message]
2023-11-08 12:01 ` [Bug c++/112439] Modification of a member overlapping with a [[no_unique_address]] member in the constructor is incorrectly rejected in constant evaluation redi at gcc dot gnu.org
2023-11-08 13:55 ` [Bug c++/112439] [13/14 Regression] " ppalka at gcc dot gnu.org
2024-02-01 22:07 ` [Bug c++/112439] [13/14 Regression] Modification of a member overlapping with a [[no_unique_address]] member in the constructor is incorrectly rejected in constant evaluation since r13-160-g967cdbe6629653 jason at gcc dot gnu.org
2024-02-02  3:22 ` cvs-commit at gcc dot gnu.org
2024-02-02 15:57 ` cvs-commit at gcc dot gnu.org
2024-02-02 16:12 ` jason at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-112439-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).