public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "miro.palmu at helsinki dot fi" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/113021] [constexpr] gcc rejects initializing struct containing vector during constant evaluation depending if the struct also contains other member Date: Fri, 15 Dec 2023 10:55:23 +0000 [thread overview] Message-ID: <bug-113021-4-P7kr2tEWG0@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-113021-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113021 --- Comment #3 from Miro Palmu <miro.palmu at helsinki dot fi> --- Here is even more reduced. Notice that if the unused data member `pointer` is removed from `vec` the problem goes away. Same with data member `a` in struct `A`. ``` struct vec { int data; int* pointer; // This is required for compilation to fail constexpr vec() { data = 42; } }; struct A { vec v; int a; // This is required for compilation to fail }; consteval auto foo() { A temp1{{}, 42}; // This compiles fine const A tmp2{{}, 42}; // This does not } int main() { foo(); } ```
next prev parent reply other threads:[~2023-12-15 10:55 UTC|newest] Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top 2023-12-14 14:25 [Bug c++/113021] New: " miro.palmu at helsinki dot fi 2023-12-14 17:35 ` [Bug c++/113021] " pinskia at gcc dot gnu.org 2023-12-15 10:44 ` miro.palmu at helsinki dot fi 2023-12-15 10:55 ` miro.palmu at helsinki dot fi [this message] 2023-12-15 19:40 ` pinskia 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-113021-4-P7kr2tEWG0@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).