This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
Other format: | [Raw text] |
This is not a bug and here is why: obj2(int a) { obj(a); } // overloaded constructor
what this really is obj a; and not calling of the constructor. try this instead: obj2(int a): obj (a) {}
Because in one case the parser is parsing it as a function call while in the other case it is parsing as variable. The reason why it does it that way is because it is ambiguous otherwise so the C++ standard decided that it will be used to declare a variable instead of a function call to the constructor if the first thing is a type also. I cannot quote the standard word for word on this matter.
Thanks, Andrew Pinski
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |