[Bug c++/55159] pythy constexpr auto lambda pointer has no initializer
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55159 Paolo Carlini changed: What|Removed |Added Status|NEW |RESOLVED CC||paolo.carlini at oracle dot ||com Resolution||DUPLICATE --- Comment #10 from Paolo Carlini 2012-11-07 16:11:28 UTC --- Oh, Comment #7 is really the same as PR55003. *** This bug has been marked as a duplicate of bug 55003 ***
[Bug c++/55159] pythy constexpr auto lambda pointer has no initializer
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55159 Paolo Carlini changed: What|Removed |Added Status|UNCONFIRMED |NEW Last reconfirmed||2012-11-07 Ever Confirmed|0 |1 --- Comment #9 from Paolo Carlini 2012-11-07 15:42:04 UTC --- Uhm, for testcase in Comment #7 we call finish_static_data_member_decl from instantiate_class_template_1 and we explicitly pass init == NULL_TREE, no chances for things to work from this point on. Interestingly this is the *only* place in pt.c where we call finish_static_data_member_decl.
[Bug c++/55159] pythy constexpr auto lambda pointer has no initializer
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55159 Paolo Carlini changed: What|Removed |Added Blocks||55004 --- Comment #8 from Paolo Carlini 2012-11-02 11:48:39 UTC --- Ah, Ok, I was a bit lost ;) Thanks. However, my (very rough) feeling is that we have got already quite a bit in Bugzilla in the area, constexpr, auto, pointers...
[Bug c++/55159] pythy constexpr auto lambda pointer has no initializer
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55159 --- Comment #7 from Daniel Krügler 2012-11-02 11:39:07 UTC --- (In reply to comment #6) > Thus, Daniel, is this invalid? I think this part of the problem is indeed valid: template struct min_t { static bool less(T0 x, T1 y) { return x < y ? x : y; } constexpr static auto* f = &less; // #5 }; min_t mi; // #8 "8| required from here| 5|error: declaration of 'constexpr auto* const min_t::f' has no initializer" (With or without & in front of less) According to my understanding this should be accepted.
[Bug c++/55159] pythy constexpr auto lambda pointer has no initializer
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55159 --- Comment #6 from Paolo Carlini 2012-11-02 11:14:54 UTC --- Thus, Daniel, is this invalid?
[Bug c++/55159] pythy constexpr auto lambda pointer has no initializer
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55159 --- Comment #5 from Daniel Krügler 2012-11-02 08:57:33 UTC --- I need to insert another correction. My attempt to simplify the reporters bug failed because I was mislead by the report description that "visual studio 2012 work fine" interpreting this to mean the Microsoft Visual Studio 2012 compiler. But that one does not understand 'constexpr' therefore my reduction to 'const' was not equivalent. (In reply to comment #1) > 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. This statement still holds. The original code is not conforming. The following presents a conforming code that reproduces the problem: template struct min_t { static bool less(T0 x, T1 y) { return x < y ? x : y; } constexpr static auto* f = &less; // #5 }; min_t mi; // #8 "8| required from here| 5|error: declaration of 'constexpr auto* const min_t::f' has no initializer" Please ignore the part about const T in template deduction. This is a different issue and not related to this one.
[Bug c++/55159] pythy constexpr auto lambda pointer has no initializer
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55159 --- Comment #4 from Daniel Krügler 2012-11-02 08:10:14 UTC --- (In reply to comment #3) > But it seems that gcc doesn't ignore the const (in "const T*" or "const > auto*") > for functions here, which seems to be the root of the second problem (This is > *not* attempting to form a function with cv-qualifier-seq). I withdraw my interpretation that it is *clear* here that during template argument deduction we can successfully match a "const T" with a function type. This looks like a core language problem to me and I'll notify CWG in regard to this.
[Bug c++/55159] pythy constexpr auto lambda pointer has no initializer
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55159 --- Comment #3 from Daniel Krügler 2012-11-01 15:11:51 UTC --- (In reply to comment #2) Hmmh, it doesn't look like that one, maybe I was wrong about an existing issue. But it seems that gcc doesn't ignore the const (in "const T*" or "const auto*") for functions here, which seems to be the root of the second problem (This is *not* attempting to form a function with cv-qualifier-seq). Both template T* addr(T& t) { return &t; } bool less(int x, int y) { return x < y ? x : y; } static auto* f = addr(less); and template T* addr(T& t) { return &t; } bool less(int x, int y) { return x < y ? x : y; } template int deduce(T*) { return 0; } int i = deduce(addr(less)); are accepted as they should.
[Bug c++/55159] pythy constexpr auto lambda pointer has no initializer
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55159 --- Comment #2 from Paolo Carlini 2012-11-01 14:25:26 UTC --- Daniel, you mean PR54111 maybe?
[Bug c++/55159] pythy constexpr auto lambda pointer has no initializer
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55159 Daniel Krügler changed: What|Removed |Added CC||daniel.kruegler at ||googlemail dot com --- Comment #1 from Daniel Krügler 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 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 T* addr(T& t) { return &t; } bool less(int x, int y) { return x < y ? x : y; } template 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 int deduce(const T*)| note: template argument deduction/substitution failed:| note: types 'const T' and 'bool(int, int)' have incompatible cv-qualifiers"