From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29474 invoked by alias); 12 Apr 2012 23:45:27 -0000 Received: (qmail 29464 invoked by uid 22791); 12 Apr 2012 23:45:26 -0000 X-SWARE-Spam-Status: No, hits=-3.5 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from localhost (HELO gcc.gnu.org) (127.0.0.1) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 12 Apr 2012 23:45:14 +0000 From: "drwowe at yahoo dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/52966] New: ill-formed template constexpr functions are accepted? Date: Thu, 12 Apr 2012 23:45:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Keywords: X-Bugzilla-Severity: minor X-Bugzilla-Who: drwowe at yahoo 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: Message-ID: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" 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-04/txt/msg00955.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52966 Bug #: 52966 Summary: ill-formed template constexpr functions are accepted? Classification: Unclassified Product: gcc Version: unknown Status: UNCONFIRMED Severity: minor Priority: P3 Component: c++ AssignedTo: unassigned@gcc.gnu.org ReportedBy: drwowe@yahoo.com The following code successfully compiles on g++ 4.7.0 with -std=c++11. I'm not a language lawyer, but it seems like it shouldn't since the A::two() function breaks the constexpr rules, either at template definition or template instantiation time. ------ template struct A { static int two_nonconst() { return 2; } static constexpr int two() { return two_nonconst(); } } constexpr int two() { return A::two(); } ------ There is no error message until you actually try to use the two() function in an appropriate context, which could be very confusing. ------ int x[two()]; ------ error: size of array 'x' is not an integral constant-expression