This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/64547] New: A non-const constexpr function is rejected incorrectly
- From: "ville.voutilainen at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Fri, 09 Jan 2015 05:35:54 +0000
- Subject: [Bug c++/64547] New: A non-const constexpr function is rejected incorrectly
- Auto-submitted: auto-generated
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64547
Bug ID: 64547
Summary: A non-const constexpr function is rejected incorrectly
Product: gcc
Version: 5.0
Status: UNCONFIRMED
Keywords: rejects-valid
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: ville.voutilainen at gmail dot com
CC: jason at redhat dot com
struct X
{
int x;
constexpr int get() const {return x;}
constexpr void set(int foo) {x = foo;}
};
constexpr int bar()
{
X x{42};
x.set(666);
return x.get();
}
int main()
{
constexpr int foo = bar();
}
Clang accepts the code, gcc rejects with
constexpr-member.cpp: In function âint main()â:
constexpr-member.cpp:17:28: in constexpr expansion of âbar()â
constexpr-member.cpp:11:10: in constexpr expansion of âx.X::set(666)â
constexpr-member.cpp:17:29: error: constexpr call flows off the end of the
function
constexpr int foo = bar();