From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 13771 invoked by alias); 6 Oct 2010 23:58:18 -0000 Received: (qmail 13760 invoked by uid 22791); 6 Oct 2010 23:58:17 -0000 X-SWARE-Spam-Status: No, hits=-2.6 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; Wed, 06 Oct 2010 23:58:12 +0000 From: "bkoz at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/45923] New: constexpr diagnostic w/ non-literal 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: normal X-Bugzilla-Who: bkoz at gcc dot gnu.org 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 Date: Wed, 06 Oct 2010 23:58:00 -0000 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: 2010-10/txt/msg00587.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D45923 Summary: constexpr diagnostic w/ non-literal Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassigned@gcc.gnu.org ReportedBy: bkoz@gcc.gnu.org This is pretty minor, but thought I'd point it out. struct complex=20 { #if 0 constexpr complex(double r, double i) : re(r), im(i) { }=20 #else complex(double r, double i) : re(r), im(i) { }=20 #endif constexpr double real() { return re; } double imag() const { return im; } private: double re;=20 double im; }; constexpr complex co1(0, 1); // literal object //constant expression data initialized by a user-defined literal constexpr double dd2 =3D co1.real(); // OK with: %$bin/H-x86_64-gcc-constexpr.20101004/bin/g++ --version g++ (GCC) 4.6.0 20101004 (experimental) like so: %$bin/H-x86_64-gcc-constexpr.20101004/bin/g++ -std=3Dc++0x -c constexpr-bas= ic.cc gives: constexpr-basic.cc:9:20: error: enclosing class of =E2=80=98constexpr double complex::real() const=E2=80=99 is not a literal type YES! Except the member function signature for real() has a superfulous "con= st" constexpr-basic.cc:17:27: error: the type =E2=80=98const complex=E2=80=99 o= f constexpr variable =E2=80=98co1=E2=80=99 is not literal YES! Except this is more like "invalid definition of constexpr variable 'co= 1' of non-literal type 'complex' constexpr-basic.cc:20:33: error: =E2=80=98double complex::real() const=E2= =80=99 is not a constexpr function NO! Perhaps the last one should read:=20 constexpr-basic.cc:20:33: error: member function =E2=80=98constexpr double complex::real()=E2=80=99 cannot be used in a constant expression with a non= -literal object Or something.