[Bug c++/64547] New: A non-const constexpr function is rejected incorrectly
ville.voutilainen at gmail dot com
gcc-bugzilla@gcc.gnu.org
Fri Jan 9 05:36:00 GMT 2015
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();
More information about the Gcc-bugs
mailing list