[Bug c++/55080] New: -pedantic produces error: floating-point literal cannot appear in a constant-expression

manu at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Fri Oct 26 11:35:00 GMT 2012


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

             Bug #: 55080
           Summary: -pedantic produces error: floating-point literal
                    cannot appear in a constant-expression
    Classification: Unclassified
           Product: gcc
           Version: 4.8.0
            Status: UNCONFIRMED
          Keywords: accepts-invalid
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: manu@gcc.gnu.org
                CC: fang@csl.cornell.edu, manu@gcc.gnu.org, matz@suse.de,
                    papadopo@shfj.cea.fr, rearnsha@gcc.gnu.org,
                    rguenth@gcc.gnu.org, rnewman@compubrite.com
        Depends on: 11393
             Build: any


+++ This bug was initially created as a clone of Bug #11393 +++

class B { 
 static const int c = 3.1415926;
};


-std=c++98 -pedantic gives
error: floating-point literal cannot appear in a constant-expression
  static const int c = 3.1415926;
                       ^

and -std=c++98 gives nothing. Both -std=c++11 -pedantic and just -std=c++11
report nothing.

This is a bug. -pedantic should not produce errors. If this is a GNU extension
in c++98 mode, then it should produce a warning like:

warning: ISO C++98 forbids using a floating-point literal in a
constant-expression [-Wpedantic]



More information about the Gcc-bugs mailing list