From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26924 invoked by alias); 1 Nov 2012 10:58:37 -0000 Received: (qmail 26832 invoked by uid 48); 1 Nov 2012 10:58:08 -0000 From: "daniel.kruegler at googlemail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/55159] pythy constexpr auto lambda pointer has no initializer Date: Thu, 01 Nov 2012 10:58:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: daniel.kruegler at googlemail dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: CC Message-ID: In-Reply-To: References: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2012-11/txt/msg00032.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D55159 Daniel Kr=C3=BCgler changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |daniel.kruegler at | |googlemail dot com --- Comment #1 from Daniel Kr=C3=BCgler 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 definiti= on 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 =3D addr(less); indeed points to a defect of gcc, not being able to deduce auto here. I thi= nk this is the same bug that I can remember (but cannot find at the very momen= t) 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 =3D 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-qualifier= s"