From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2584 invoked by alias); 31 Mar 2012 16:19:34 -0000 Received: (qmail 2569 invoked by uid 22791); 31 Mar 2012 16:19:30 -0000 X-SWARE-Spam-Status: No, hits=-3.0 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; Sat, 31 Mar 2012 16:19:17 +0000 From: "potswa at mac dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/52809] New: Template non-dependent static_assert diagnostics may confuse Date: Sat, 31 Mar 2012 16:55: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: potswa at mac 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" 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-03/txt/msg02748.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D52809 Bug #: 52809 Summary: Template non-dependent static_assert diagnostics may confuse Classification: Unclassified Product: gcc Version: 4.7.0 Status: UNCONFIRMED Severity: minor Priority: P3 Component: c++ AssignedTo: unassigned@gcc.gnu.org ReportedBy: potswa@mac.com A static_assert declaration that does not depend on template parameters wil= l be detected and reported while parsing the template, before any instantiation. This is OK because such a template would have no valid instantiation, which immediately renders the program ill-formed. In terms of cosmetic QOI, however, it would be better to clarify the messag= es for users who don't know all the rules. Intuitively, the assertion shouldn'= t be evaluated until instantiation, regardless of dependence. The user might exp= ect an uninstantiated template to pass through. We should add something like "error: template MyTemplate cannot have a valid instantiation" after the static_assert diagnostic. Example code and result, as currently implemented: template< bool b > struct s { static_assert( b, "uhoh" ); static_assert( false, "yikes" ); }; s< false > q; depassert.cpp:4:1: error: static assertion failed: yikes depassert.cpp: In instantiation of =E2=80=98struct s=E2=80=99: depassert.cpp:7:12: required from here depassert.cpp:3:1: error: static assertion failed: uhoh