[Bug c++/23698] [4.1 Regression] accepts invalid

bangerth at dealii dot org gcc-bugzilla@gcc.gnu.org
Fri Sep 2 16:34:00 GMT 2005


------- 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 ‘X<S>’: 
x.cc:16:   instantiated from here 
x.cc:2: error: conversion from ‘bool’ to non-scalar type ‘S’ requested 
x.cc:2: error: invalid in-class initialization of static data member of 
non-integral type ‘const S’ 
 
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



More information about the Gcc-bugs mailing list