public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/45923] New: constexpr diagnostic w/ non-literal
@ 2010-10-06 23:58 bkoz at gcc dot gnu.org
  2010-10-07 15:35 ` [Bug c++/45923] " jason at gcc dot gnu.org
                   ` (14 more replies)
  0 siblings, 15 replies; 16+ messages in thread
From: bkoz at gcc dot gnu.org @ 2010-10-06 23:58 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45923

           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 
{
#if 0
  constexpr complex(double r, double i) : re(r), im(i) { } 
#else
  complex(double r, double i) : re(r), im(i) { } 
#endif
  constexpr double real() { return re; }
  double imag() const { return im; }

private:
  double re; 
  double im;
};

constexpr complex co1(0, 1); // literal object

//constant expression data initialized  by a user-defined literal
constexpr double dd2 = 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=c++0x -c constexpr-basic.cc

gives:
constexpr-basic.cc:9:20: error: enclosing class of ‘constexpr double
complex::real() const’ is not a literal type

YES! Except the member function signature for real() has a superfulous "const"

constexpr-basic.cc:17:27: error: the type ‘const complex’ of constexpr variable
‘co1’ is not literal

YES! Except this is more like "invalid definition of constexpr variable 'co1'
of non-literal type 'complex'

constexpr-basic.cc:20:33: error: ‘double complex::real() const’ is not a
constexpr function

NO!

Perhaps the last one should read: 

constexpr-basic.cc:20:33: error: member function ‘constexpr double
complex::real()’ cannot be used in a constant expression with a non-literal
object

Or something.


^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2011-07-25 23:59 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-10-06 23:58 [Bug c++/45923] New: constexpr diagnostic w/ non-literal bkoz at gcc dot gnu.org
2010-10-07 15:35 ` [Bug c++/45923] " jason at gcc dot gnu.org
2010-10-08 17:12 ` bkoz at redhat dot com
2010-10-08 18:38 ` jason at gcc dot gnu.org
2010-11-03 17:32 ` bkoz at gcc dot gnu.org
2010-11-03 17:37 ` bkoz at gcc dot gnu.org
2010-11-03 17:42 ` bkoz at gcc dot gnu.org
2010-11-03 20:48 ` bkoz at gcc dot gnu.org
2010-11-03 20:55 ` bkoz at gcc dot gnu.org
2010-11-11  4:54 ` [Bug c++/45923] constexpr diagnostics, more more bkoz at gcc dot gnu.org
2010-11-24 21:00 ` bkoz at gcc dot gnu.org
2011-01-20 20:00 ` bkoz at gcc dot gnu.org
2011-06-27  4:10 ` jason at gcc dot gnu.org
2011-06-29 14:36 ` jason at gcc dot gnu.org
2011-07-05  3:53 ` b.r.longbons at gmail dot com
2011-07-25 23:59 ` jason at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).