Here's another one for the gurus.

The following code compiles in GCC 4.7.3. However, if you go to the implementation of the destructor (near the end), and replace the line marked "Compiles" with the commented out line that follows it, you will get a compile-time error.

Fine -- so it's a syntax error. The odd thing, though, is that if you then proceed to comment out the coercion constructor from the template (and remove the definition of cf1 from main(), of course), the error goes away.

Why is this?

Code:// Template declaration: template<class T> class C { public: T val; C(C const& that); // Copy constructor C(T const& thing); // Argument constructor template <class U> // Coercion constructor; assumes T=U is defined C(C<U> const& thatU); ~C(); // Destructor }; // Template implementation: template<class T> // Copy constructor implementation C<T>::C(C<T> const& that) { val = that.val; } template<class T> // Argument constructor implementation C<T>::C(T const& thing) { val = thing; } template<class T> // Coercion constructor implementation template<class U> C<T>::C(C<U> const& thatU) { val = thatU.val; } template<class T> // Destructor implementation C<T>::~C() // Compiles //C<T>::~C<T>() // "error: expected identifier", *if* coercion exists { } int main() { C<int> ci1(3); // Argument construction C<int> ci2(ci1); // Copy construction C<float> cf1(ci1); // Coercion }