[Bug c++/23437] [3.4/4.0/4.1 Regression] error: ... cannot appear in a constant-expression

pannuri at cavs dot msstate dot edu gcc-bugzilla@gcc.gnu.org
Mon Sep 12 18:39:00 GMT 2005


------- Additional Comments From pannuri at cavs dot msstate dot edu  2005-09-12 18:39 -------
It seems this works:
#include <math.h>
 #include <stdio.h>

 static const double PI = M_PI;
 static const double TWO_PI = (2.0*PI);
 static const double HALF_PI = (M_PI_2);
 static const double QUARTER_PI = (M_PI_4);

 main (int argc, char** argv) {
  int i = 0;
  printf("%ld\n", i);
  return 0;
 }

But putting these inside of a class doesn't work:

class Foo {
  Foo(){};
  ~Foo(){};
  static const double PI = M_PI;
  static const double TWO_PI = (2.0*PI);
  static const double HALF_PI = (M_PI_2);
  static const double QUARTER_PI = (M_PI_4);
};

-Madhulika 

-- 


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



More information about the Gcc-bugs mailing list