[Bug c++/55159] pythy constexpr auto lambda pointer has no initializer
daniel.kruegler at googlemail dot com
gcc-bugzilla@gcc.gnu.org
Thu Nov 1 10:58:00 GMT 2012
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55159
Daniel Krügler <daniel.kruegler at googlemail dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |daniel.kruegler at
| |googlemail dot com
--- Comment #1 from Daniel Krügler <daniel.kruegler at googlemail dot com> 2012-11-01 10:58:06 UTC ---
I really think that Pythy should fix this implementation, because it is not
supported by the C++11 standard. Any compiler accepting that is defect.
According to 9.4.2 p3:
"A static data member of literal type can be declared in the class definition
with the constexpr specifier; if so, its declaration shall specify a
brace-or-equal-initializer in which every initializer-clause that is an
assignment-expression is a constant expression."
As of 5.19 p2 the appearance of a lambda-expression prevents an expression from
satisfying the requirements of a (core) constant expression.
But changing your example to
template <typename T>
T* addr(T& t) { return &t; }
bool less(int x, int y) { return x < y ? x : y; }
const static auto* f = addr(less);
indeed points to a defect of gcc, not being able to deduce auto here. I think
this is the same bug that I can remember (but cannot find at the very moment)
which shows a similar problem during overload resolution in templates when
involving function addresses such as in
template <typename T>
T* addr(T& t) { return &t; }
bool less(int x, int y) { return x < y ? x : y; }
template<typename T>
int deduce(const T*) { return 0; }
int i = deduce(addr(less));
This example should be accepted, but gcc doesn't like it saying:
"error: no matching function for call to 'deduce(bool (*)(int, int))'|
note: candidate is:|
note: template<class T> int deduce(const T*)|
note: template argument deduction/substitution failed:|
note: types 'const T' and 'bool(int, int)' have incompatible cv-qualifiers"
More information about the Gcc-bugs
mailing list