Bug with enum computations
Todd Veldhuizen
todd@p200.cybervision.com
Sun Sep 7 05:48:00 GMT 1997
This is a bug report against the 970904 snapshot. I have Mark Mitchell's
member template patches installed, but this code doesn't use member templates.
I tried deinstalling the patches, but without success -- if this compiles
fine without the patches, it should be redirected to Mark.
1. In the code below, gcc complains that Y<X,X>::a does not exist. This
problem goes away if the "n = meta_max<...>::max" line in Y is replaced
with an inlined version (see comment). Somehow the use of meta_max causes
Y<X,X>::a to disappear.
2. If the code below is compiled with -DNO_META_MAX, an internal
compiler error occurs.
#ifndef NO_META_MAX
template<int N1, int N2>
struct meta_max {
enum { max = (N1 > N2) ? N1 : N2 };
};
#endif
struct X {
enum {
a = 0,
n = 0
};
};
template<class T1, class T2>
struct Y {
enum {
a = T1::a + T2::a,
// NB: if the next line is changed to
// n = (T1::n > T2::n) ? T1::n : T2::n
// the problem goes away.
n = meta_max<T1::n,T2::n>::max
};
};
int z = Y<X,X>::a;
More information about the Gcc-bugs
mailing list