------- Additional Comments From bangerth at dealii dot org  2005-09-02 16:33 
-------
I think it can be considered arguable whether the code is valid or not. 
Here it is again: 
-------------------- 
template <typename T> struct X { 
    static const T value = false; 
}; 
 
template <bool> struct W {}; 
 
template <typename T> 
W<X<T>::value> 
operator== (int, T)   {} 
 
struct S { 
    bool operator== (const S&) const; 
}; 
 
S t1, t2; 
bool b = (t1 == t2); 
-------------------------- 
g/x> /home/bangerth/bin/gcc-4.1*/bin/c++ -c x.cc 
g/x> /home/bangerth/bin/gcc-4.0*/bin/c++ -c x.cc 
x.cc: In instantiation of &#8216;X<S>&#8217;: 
x.cc:16:   instantiated from here 
x.cc:2: error: conversion from &#8216;bool&#8217; to non-scalar type 
&#8216;S&#8217; requested 
x.cc:2: error: invalid in-class initialization of static data member of 
non-integral type &#8216;const S&#8217; 
 
The question is whether we have to instantiate X<S> at all if we can 
determine that we will not call ::operator==(int,T). 
 
W. 

-- 


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

Reply via email to