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:44:45 +0000 [thread overview]
Message-ID: <bug-113021-4-P82fZTgRpS@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 #2 from Miro Palmu <miro.palmu at helsinki dot fi> ---
(In reply to Andrew Pinski from comment #1)
> Confirmed. We should reduce this to remove the include file too ...
Here is somewhat reduced:
```
#include <memory>
auto alloc = std::allocator<int>{};
constexpr auto n = 3;
struct vec {
int* data;
constexpr vec() {
this->data = alloc.allocate(n);
}
constexpr ~vec() {
alloc.deallocate(this->data, n);
}
};
struct A {
vec v;
int a;
};
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:44 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 [this message]
2023-12-15 10:55 ` miro.palmu at helsinki dot fi
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-P82fZTgRpS@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).