From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 67A263858C2C; Mon, 17 Apr 2023 12:43:00 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 67A263858C2C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1681735380; bh=b62+aAh5+p/KfEYVl6POu3AbjiWP1nROPbvuQsdBzDk=; h=From:To:Subject:Date:From; b=d5Z9qNqBHd0RRZVXKGzjqJ1wcj/mHDajwYcot8ptisdPOo+s/TaaMr+XSmFYoy+2e pIHbmrbYFTYQ3g1zbQZi6DxTHrxk+YtaMVdERvnWUh7D26qz9YzPGm6L5SoaRWemLK IKP1rHEQv0soPjET7zwwu6yMtVl70Z8b4Qoi1oe0= From: "terra at gnome dot 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 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: libstdc++ X-Bugzilla-Version: 12.1.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: terra at gnome dot org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone attachments.created Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D109536 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=3D54875&action=3Dedit Preprocessed source code The following program fails to compile with -std=3Dgnu++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 pro= blem (without -D...) other than "farm" being unused. ------------------------------------------------------------- #include constexpr int foo () { std::vector v { 1, 2, 3 }; return v.size(); } constexpr int farm =3D foo (); ------------------------------------------------------------- # /usr/local/products/gcc/12.1.0/bin/g++ -D_GLIBCXX_DEBUG -std=3Dgnu++20 -= Wall -c www.C www.C: In function =E2=80=98constexpr int foo()=E2=80=99: www.C:7:20: error: variable =E2=80=98v=E2=80=99 of non-literal type =E2=80= =98std::__debug::vector=E2=80=99 in =E2=80=98constexpr=E2=80=99 function only available with =E2=80=98-std= =3Dc++2b=E2=80=99 or =E2=80=98-std=3Dgnu++2b=E2=80=99 7 | std::vector 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: =E2=80=98std::__debug::vector=E2=80=99 is not literal because: 117 | class vector | ^~~~~~ /usr/local/products/gcc/12.1.0/include/c++/12.1.0/debug/vector:117:11: note= :=20=20 =E2=80=98std::__debug::vector=E2=80=99 does not have =E2=80=98constexp= r=E2=80=99 destructor www.C: At global scope: www.C:11:26: error: =E2=80=98constexpr int foo()=E2=80=99 called in a const= ant expression 11 | constexpr int farm =3D foo (); | ~~~~^~ www.C:5:1: note: =E2=80=98constexpr int foo()=E2=80=99 declared here 5 | foo () | ^~~=