From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 184ED3858C2F; Sun, 25 Jun 2023 08:56:42 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 184ED3858C2F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1687683402; bh=/XwQBwg0oldf7/BUorc0goR5FMd4Hnt8L2fQv9tCeDU=; h=From:To:Subject:Date:From; b=U2grD1hVdeFSIQNFNxvtMzNpA8sKoO+r+ZV5ov+vSLCDxp61k/xxuHZSmxP1jR+AQ d2SNavW7pb0+eR90Zjd8g7cboRVtwlPddrdEm5gbami3nqvfCbA68Ql6bZIEFDgSmh ReF+QVcaZzfA2L3zwZlplJ0Bwnzcxom5SaiweN+Q= From: "xry111 at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/110401] New: Unhelpful "goto is not a constant expression" in ill-formed constexpr function template Date: Sun, 25 Jun 2023 08:56:41 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 14.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: xry111 at gcc dot gnu.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 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=3D110401 Bug ID: 110401 Summary: Unhelpful "goto is not a constant expression" in ill-formed constexpr function template Product: gcc Version: 14.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: xry111 at gcc dot gnu.org Target Milestone: --- #include template constexpr std::array get_sqr() { std::array ret; for (int i =3D 0; i < N; i++) ret[i] =3D i * i; return ret; } constexpr auto sqr =3D get_sqr<10000>(); GCC says "error: 'goto' is not a constant expression". This is puzzling because there is no "goto" in the function. Note that if it's not a template, GCC outputs the correct message: #include constexpr std::array get_sqr() { std::array ret; for (int i =3D 0; i < 10000; i++) ret[i] =3D i * i; return ret; } constexpr auto sqr =3D get_sqr(); t.cc: In function 'constexpr std::array get_sqr()': t.cc:5:28: error: uninitialized variable 'ret' in 'constexpr' function 5 | std::array ret; | ^~~=