This is the mail archive of the gcc-bugs@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]

g++-3.4: static const bool in template struct rejected - why?


Hi!

Maybe I am again missing some (new) detail of the C++ standard, so
forgive me if this ain't a bug and enlighten me.

-------------------------------------------
template <class T1, class T2>
struct Is { static const bool SameType = false; };

template <class T>
struct Is<T, T> { static const bool SameType = true; };

#define SAME_TYPE(T1, T2) Is<T1, T2>::SameType


template <class T>
struct Test
{
  static const bool test1 = SAME_TYPE(double, T);
  static const bool test2 = false;

  static const bool result = test1 || test2;
};


int main() {
  Test<double> T1;
}
-------------------------------------------

# g++ GCC-3.4-CannotAppearInConstantExpr.C
GCC-3.4-CannotAppearInConstantExpr.C:16: error: `
   Test<T>::test1' cannot appear in a constant-expression





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