[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Bug#171123: g++-3.2: incorrect use of default assignment operator?



Ben Burton <bab@debian.org> writes:

> I would have expected a compile error, since the declaration
> "Foo bar = foo;" tries to use the non-existant default constructor for
> class Foo.

No, it doesn't. This is not a initialization followed by an assignment
operator; there is no assignment operator at all in this statement.
Instead, it is a copy-initialization, which invokes the copy
constructor.

> Perhaps I'm just misunderstanding the finer details of the C++ specs?

The difference between initialization and assignment should be
explained in every C++ text book. In the C++ standard, it is defined
in section 8.5, [dcl.init]/12. 

In short: you program is well-formed, and the compiler is correct in
accepting it; this is not a bug.

Regards,
Martin



Reply to: