public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "jan.kokemueller at gmail dot com" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/98995] [11/12/13/14 Regression] Copy elision not applied to members declared with [[no_unique_address]] or a empty base class Date: Fri, 27 Oct 2023 13:55:48 +0000 [thread overview] Message-ID: <bug-98995-4-hwzIDEEmzN@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-98995-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98995 Jan Kokemüller <jan.kokemueller at gmail dot com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jan.kokemueller at gmail dot com --- Comment #13 from Jan Kokemüller <jan.kokemueller at gmail dot com> --- Sometimes, all of the padding bytes of a "[[no_unique_address]]" member are known when designing a class. It would be great if there was a way to say: "hey, it's OK to do guaranteed copy elision here". Example: union U { [[no_unique_address]] Val val; [[no_unique_address]] Err err; }; struct R { [[no_unique_address]] U union; [[no_unique_address]] bool has_val; }; struct expected { R r; }; In this example, "union U" and "struct R" are only used in the "struct expected", by design. So it should be safe to allow guaranteed copy elision when initializing the members "val" and "err" of the union since we have full control over the tail padding bytes (there can only be "has_val" in there, nothing else). Maybe there could be an attribute, something like "[[gnu::allow_guaranteed_copy_elision]]" or "[[gnu::defer_temporary_materialization]]", to mark those members where guaranteed copy elision is safe? So you could have: union U { [[no_unique_address,gnu::defer_temporary_materialization]] Val val; [[no_unique_address,gnu::defer_temporary_materialization]] Err err; }; What do you think?
prev parent reply other threads:[~2023-10-27 13:55 UTC|newest] Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-02-08 0:53 [Bug c++/98995] New: Copy elision not applied to members declared with [[no_unique_address]] david at doublewise dot net 2021-02-08 9:36 ` [Bug c++/98995] [11 Regression] " rguenth at gcc dot gnu.org 2021-02-08 12:15 ` redi at gcc dot gnu.org 2021-02-08 20:37 ` jason at gcc dot gnu.org 2021-04-27 11:40 ` [Bug c++/98995] [11/12 " jakub at gcc dot gnu.org 2021-07-28 7:05 ` rguenth at gcc dot gnu.org 2022-04-21 7:48 ` rguenth at gcc dot gnu.org 2022-04-28 15:12 ` [Bug c++/98995] [11/12/13 " davidfromonline at gmail dot com 2023-01-08 6:45 ` pinskia at gcc dot gnu.org 2023-01-08 6:46 ` [Bug c++/98995] [10/11/12/13 " pinskia at gcc dot gnu.org 2023-01-10 21:35 ` [Bug c++/98995] [10/11/12/13 Regression] Copy elision not applied to members declared with [[no_unique_address]] or a empty base class pinskia at gcc dot gnu.org 2023-02-06 14:20 ` redi at gcc dot gnu.org 2023-02-13 16:12 ` pinskia at gcc dot gnu.org 2023-06-30 20:09 ` [Bug c++/98995] [10/11/12/13/14 " pinskia at gcc dot gnu.org 2023-07-07 10:39 ` [Bug c++/98995] [11/12/13/14 " rguenth at gcc dot gnu.org 2023-10-27 13:55 ` jan.kokemueller at gmail dot com [this message]
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-98995-4-hwzIDEEmzN@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: linkBe 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).