help-gplusplus
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

g++ 3.3.2 '?:' operator compile error


From: Kyuso Cahi
Subject: g++ 3.3.2 '?:' operator compile error
Date: Sat, 01 May 2004 02:30:02 GMT
User-agent: KNode/0.7.2

I have the following code that gives an error during compile:

// xxx.cc
class A {
 public:
  static const int YES=1;
  static const int NO=-1;
};

int main() {
  double n=3.0;
  if (A::YES > A::NO); // line 9
  return (n>0.0) ? (A::YES) : (A::NO); // line 10
}

---after g++ 3.3.2 compiling--
/tmp/ccCrBdd3.o(.text+0x33): In function `main':
xxx.cc:10: undefined reference to `A::YES'
/tmp/ccCrBdd3.o(.text+0x3d):xxx.cc:10: undefined reference to `A::NO'

It seems that some class members cannot be referenced inside the ?:
operator. You can see that line 9 doesn't have compile error for A::YES nor
A::NO. I also found that compiling with -O2 causes error only on A::YES but
not on A::NO.

Is this a bug? What's so special about '?:' operator that causes this error?



reply via email to

[Prev in Thread] Current Thread [Next in Thread]