public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "luto at mit dot edu" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/54020] New: [c++0x] incorrectly accepted constexpr functions Date: Wed, 18 Jul 2012 19:34:00 -0000 [thread overview] Message-ID: <bug-54020-4@http.gcc.gnu.org/bugzilla/> (raw) http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54020 Bug #: 54020 Summary: [c++0x] incorrectly accepted constexpr functions Classification: Unclassified Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassigned@gcc.gnu.org ReportedBy: luto@mit.edu Tested on a somewhat recent trunk build as well as 4.7-some branch version. // Preliminaries. extern int nonconst_func(int); constexpr int identity(int x) { return x; } constexpr int zero() { return identity(0); } constexpr int one() { return identity(1); } // Correctly accepted. constexpr int three = one() ? 3 : nonconst_func(0); // Incorrectly accepted. See [dcl.constexpr] #5: // For a constexpr function, if no function argument values exist // such that the function invocation sub-stitution would produce a // constant expression (5.19), the program is ill-formed; no diagnostic // required. constexpr int bogus() { return zero () ? 3 : nonconst_func(0); } // Correctly rejected (not sure why). constexpr int correct_error() { return nonconst_func(0); } // Correctly rejected. constexpr int z = bogus(); // This is also correctly rejected. constexpr int correct_failure() { return 0 ? 3 : nonconst_func(0); }
next reply other threads:[~2012-07-18 19:34 UTC|newest] Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top 2012-07-18 19:34 luto at mit dot edu [this message] 2012-07-19 6:40 ` [Bug c++/54020] " jakub at gcc dot gnu.org 2012-07-19 15:42 ` luto at mit dot edu 2012-07-25 9:40 ` paolo.carlini at oracle dot com 2012-07-25 13:53 ` jason at gcc dot gnu.org 2012-07-25 14:57 ` jason at gcc dot gnu.org 2012-07-25 15:04 ` jason 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-54020-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).