[Bug c++/14779] [3.3 Regression] the copy constructor for a templatized class is not used in array initialization unless the constructor was previously referenced

bangerth at dealii dot org gcc-bugzilla@gcc.gnu.org
Thu Apr 1 13:56:00 GMT 2004


------- Additional Comments From bangerth at dealii dot org  2004-04-01 13:56 -------
Confirmed. Here's something smaller and selfcontained: 
------------------ 
extern "C" void abort (); 
 
struct S { 
    S () : self (this) {}         
    S (const S&) : self (this) {}         
    S* self; 
}; 
 
template <typename T> struct X { 
    T t; 
}; 
 
const X<S> pba[] = { X<S> () }; 
 
int main () 
{ 
  if (pba[0].t.self != &pba[0].t) 
    abort (); 
} 
---------------------- 
When the constructor or copy constructor of pba.t is run, it should set 
the 'self' pointer to the address of the object. This is what we test 
in main(), and abort if the action hasn't been performed. 
 
Here's what I get: 
g/x> /home/bangerth/bin/gcc-3.2.3/bin/c++ x.cc ; ./a.out  
g/x> /home/bangerth/bin/gcc-3.3.4-pre/bin/c++ x.cc ; ./a.out  
Aborted 
g/x> /home/bangerth/bin/gcc-3.4-pre/bin/c++ x.cc ; ./a.out  
 
So this is a regression on 3.3 only. 
 
W. 

-- 


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



More information about the Gcc-bugs mailing list