public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "terra at gnome dot org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/109536] New: Failure to compile constexpr std::vector with -D_GLIBCXX_DEBUG Date: Mon, 17 Apr 2023 12:43:00 +0000 [thread overview] Message-ID: <bug-109536-4@http.gcc.gnu.org/bugzilla/> (raw) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109536 Bug ID: 109536 Summary: Failure to compile constexpr std::vector with -D_GLIBCXX_DEBUG Product: gcc Version: 12.1.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: libstdc++ Assignee: unassigned at gcc dot gnu.org Reporter: terra at gnome dot org Target Milestone: --- Created attachment 54875 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=54875&action=edit Preprocessed source code The following program fails to compile with -std=gnu++20 -D_GLIBCXX_DEBUG due to the debug version of std::vector::~vector not being constexpr. It compiles just fine without -D_GLIBCXX_DEBUG. FWIW, clang 15 sees no problem (without -D...) other than "farm" being unused. ------------------------------------------------------------- #include <vector> constexpr int foo () { std::vector<int> v { 1, 2, 3 }; return v.size(); } constexpr int farm = foo (); ------------------------------------------------------------- # /usr/local/products/gcc/12.1.0/bin/g++ -D_GLIBCXX_DEBUG -std=gnu++20 -Wall -c www.C www.C: In function ‘constexpr int foo()’: www.C:7:20: error: variable ‘v’ of non-literal type ‘std::__debug::vector<int>’ in ‘constexpr’ function only available with ‘-std=c++2b’ or ‘-std=gnu++2b’ 7 | std::vector<int> v { 1, 2, 3 }; | ^ In file included from /usr/local/products/gcc/12.1.0/include/c++/12.1.0/vector:74, from www.C:1: /usr/local/products/gcc/12.1.0/include/c++/12.1.0/debug/vector:117:11: note: ‘std::__debug::vector<int>’ is not literal because: 117 | class vector | ^~~~~~ /usr/local/products/gcc/12.1.0/include/c++/12.1.0/debug/vector:117:11: note: ‘std::__debug::vector<int>’ does not have ‘constexpr’ destructor www.C: At global scope: www.C:11:26: error: ‘constexpr int foo()’ called in a constant expression 11 | constexpr int farm = foo (); | ~~~~^~ www.C:5:1: note: ‘constexpr int foo()’ declared here 5 | foo () | ^~~
next reply other threads:[~2023-04-17 12:43 UTC|newest] Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top 2023-04-17 12:43 terra at gnome dot org [this message] 2023-04-17 20:41 ` [Bug libstdc++/109536] " jakub at gcc dot gnu.org 2023-04-17 20:41 ` jakub at gcc dot gnu.org 2023-04-18 11:21 ` redi at gcc dot gnu.org 2023-12-05 23:15 ` redi at gcc dot gnu.org 2023-12-06 14:30 ` redi at gcc dot gnu.org 2023-12-14 16:34 ` cvs-commit at gcc dot gnu.org 2023-12-14 16:35 ` redi at gcc dot gnu.org 2024-01-18 15:36 ` cvs-commit at gcc dot gnu.org 2024-01-18 16:51 ` redi 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-109536-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: 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).