This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Fw: new requirement of "constexpr" for static const float data members is too restrictive


$ cat test.cc 
struct X { static float const v=1; };

$ g++ -c -std=gnu++0x test.cc 
test.cc:1:33: error: 'constexpr' needed for in-class initialization of
static data member 'v' of non-integral type

This will break a great deal of existing c++ code preventing easy
transition to c++0x. Maybe, the constexpr requirement should be relaxed
in gnu++0x mode.

Please see the trivial patch.

Thanks
Index: gcc/cp/decl.c
===================================================================
--- gcc/cp/decl.c	(revision 167200)
+++ gcc/cp/decl.c	(working copy)
@@ -7436,7 +7436,7 @@
      in check_initializer.  */
   if (DECL_P (decl) && DECL_DECLARED_CONSTEXPR_P (decl))
     return 0;
-  else if (cxx_dialect >= cxx0x && !INTEGRAL_OR_ENUMERATION_TYPE_P (type))
+  else if (cxx_dialect >= cxx0x && !INTEGRAL_OR_ENUMERATION_TYPE_P (type) && flag_iso)
     {
       if (literal_type_p (type))
 	error ("%<constexpr%> needed for in-class initialization of static "

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]