public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "janschultke at googlemail dot com" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/114219] New: [expr.const] lvalue-to-rvalue conversion is not diagnosed to disqualify constant expressions for empty classes Date: Sun, 03 Mar 2024 08:05:52 +0000 [thread overview] Message-ID: <bug-114219-4@http.gcc.gnu.org/bugzilla/> (raw) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114219 Bug ID: 114219 Summary: [expr.const] lvalue-to-rvalue conversion is not diagnosed to disqualify constant expressions for empty classes Product: gcc Version: 14.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: janschultke at googlemail dot com Target Milestone: --- https://godbolt.org/z/jhcP8WPn8 Code to reproduce ================= struct S {}; constexpr int f(S s) { constexpr S _ = s; return 0; } S s; constexpr int _ = f(s); Issue description ================= This code compiles, but should produce errors for both constexpr initializations. According to [expr.const] p5.9, the initializers of _ cannot be constant expression because they contain lvalue-to-rvalue conversion of s, whose lifetime did not begin within the evaluation of the constant expression, and which is not usable in constant expressions. It shouldn't matter whether S is an empty class or has members; the lvalue-to-rvalue conversion in itself disqualifies expressions from being constant expressions.
next reply other threads:[~2024-03-03 8:05 UTC|newest] Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top 2024-03-03 8:05 janschultke at googlemail dot com [this message] 2024-03-03 8:10 ` [Bug c++/114219] [11/12/13/14 Regression] " pinskia at gcc dot gnu.org 2024-03-03 8:15 ` pinskia at gcc dot gnu.org 2024-03-03 8:18 ` janschultke at googlemail dot com 2024-03-03 8:21 ` pinskia at gcc dot gnu.org 2024-03-03 8:33 ` janschultke at googlemail dot com 2024-03-03 18:08 ` janschultke at googlemail dot com
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-114219-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).