public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* Fw: new requirement of "constexpr" for static const float data members is too restrictive
@ 2010-11-29 22:47 Roman Kononov
  2010-11-29 22:50 ` Andrew Pinski
  2010-11-30  0:20 ` Gabriel Dos Reis
  0 siblings, 2 replies; 22+ messages in thread
From: Roman Kononov @ 2010-11-29 22:47 UTC (permalink / raw)
  To: gcc

[-- Attachment #1: Type: text/plain, Size: 395 bytes --]

$ 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

[-- Attachment #2: constexpr-float.patch --]
[-- Type: text/x-patch, Size: 561 bytes --]

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 "

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

end of thread, other threads:[~2010-11-30 16:07 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-11-29 22:47 Fw: new requirement of "constexpr" for static const float data members is too restrictive Roman Kononov
2010-11-29 22:50 ` Andrew Pinski
2010-11-29 22:53   ` Roman Kononov
2010-11-29 23:24   ` Fw: " Marc Glisse
2010-11-30  0:20 ` Gabriel Dos Reis
2010-11-30  6:26   ` Ian Lance Taylor
2010-11-30  8:25     ` Miles Bader
2010-11-30  8:48       ` Gabriel Dos Reis
2010-11-30  9:05         ` Miles Bader
2010-11-30 11:39           ` Gabriel Dos Reis
2010-11-30 11:52             ` Miles Bader
2010-11-30 12:00               ` Gabriel Dos Reis
2010-11-30 13:08                 ` Miles Bader
2010-11-30 13:53           ` Richard Guenther
2010-11-30 14:07             ` Marc Glisse
2010-11-30 14:34             ` Miles Bader
2010-11-30 15:18             ` Gabriel Dos Reis
2010-11-30 17:40               ` Miles Bader
2010-11-30 19:04                 ` Gabriel Dos Reis
2010-11-30  8:34     ` Fw: " Andrew Pinski
2010-11-30 14:40       ` Roman Kononov
2010-11-30 19:51       ` Fw: " Ian Lance Taylor

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).