[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

jonathanu at apptechsys dot com gcc-bugzilla@gcc.gnu.org
Thu Apr 1 14:38:00 GMT 2004


------- Additional Comments From jonathanu at apptechsys dot com  2004-04-01 14:38 -------
Hmmm. I'm not sure whether that last example is a simplification because I can't
get it to stop aborting by instantiating the copy constructor explicitly. The
below snippet does succeed if the copy constructor is instantiated explicitly,
and aborts if not. And it removes the extra structure between the templatized
item and the array initialization.

I can confirm that using an explicit array bound fixes the problem on 3.3.2.

--------------------------

extern "C" void abort (); 

template <class A>
struct S { 
    S () : self (this) {}         
    S (const S&) : self (this) {}         
    S* self; 
		A a;
}; 

// S<int> a;
// S<int> b(a);

const S<int> s[] = { S<int> () };

int main () 
{ 
  if (s[0].self != &s[0]) 
    abort (); 
}


-- 


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



More information about the Gcc-bugs mailing list