static const double pi = 3.1415;

Mark Mitchell mark@codesourcery.com
Wed Feb 19 18:24:00 GMT 2003



--On Tuesday, February 18, 2003 02:07:38 PM -0800 Mike Stump 
<mrs@apple.com> wrote:

> On Tuesday, February 18, 2003, at 11:59  AM, Mark Mitchell wrote:
>> OK, Mike, let's see your patch. :-)
>
> Sure:

I'm not going to get into the language debate, even though I think it's 
interesting; my goal is to get a patch for 3.3 that pedwarns for in-class 
initialization of a floating-point static data member, and that's it. :-)

Mike, I don't quite understand your patch.

First, my version of cc1plus:

  GNU C++ version 3.4 20030218 (experimental) (i686-pc-linux-gnu)

accepts the code in your original email message:

  http://gcc.gnu.org/ml/gcc/2003-02/msg01135.html

namely:

  class A {
    static const double pi = 3.1415;
  } a;

without complaint.  In fact, the NEWS entry for 3.3, specifically says:

  (ISO C++ is even stricter; it does not allow in-class
  initializations of floating-point types.)

which implies that the floating-point extension was left in.  I believe I 
wrote that text, but I can't quite remember.

Second, in your patch you're changing a conditional that is guarded by 
(!ARITHMETIC_TYPE_P (type) && TREE_CODE (type) != ENUMERAL_TYPE) which 
means it won't fire for a floating-point type, since those types are 
arithmetic, but are not enumerations.

I'm confused.

-- 
Mark Mitchell                mark@codesourcery.com
CodeSourcery, LLC            http://www.codesourcery.com



More information about the Gcc mailing list