------- Comment #2 from Curatica at gmail dot com 2009-12-25 02:04 ------- Please, understand that for me this is just a disinterested, academic discussion: no offense. I am not sure that I agree with the theory.
The standard (8.5.1) states that: T x = a; is a "copy-initialization" but does not infer that this has anything to do with the copy constructor. If I "fix" the source by adding "const" to the copy c-tor argument: Base( const Base& b ) { /*...*/ } the code compiles indeed but there is no evidence whatsoever that the copy c-tor is being invoked when the code Base b2 = 5; is executed (as one could see, the copy c-tor prints a specific text to stdout, which does not appear in this case). Furthermore, if I take out the copy c-tor altogether, the code compiles and executes correctly. In either case, it seems clear to me that Base( int a ) { /*...*/ } is invoked. This is in accordance to "12.3.1 Conversion by constructor" in the standard [class.conv.ctor]. My guess is that different people interpreted the standard differently: the machine code is generated correctly in all cases but the compilation error which depends on the "constatness" or lack thereof of the copy c-tor argument is bogus. -- Curatica at gmail dot com changed: What |Removed |Added ---------------------------------------------------------------------------- Status|RESOLVED |UNCONFIRMED Resolution|INVALID | http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42470