[cfe-dev] Trying to work on "C++ Type-checking for copy assignment" project

Vyacheslav Kononenko vyacheslav at kononenko.net
Sat May 16 10:37:47 PDT 2009


> There may be a deeper issue here. Why is falling back to the built-in
> assignment operator the wrong thing to do? Apparently it does something
> that lets invalid cases pass. Why is that so?
If I understand correctly in C++ assignment to a class instance can be
done only by overloaded operator= implicit or explicit. So I think
case with assignment operator and class instance on the left could be
done only by overload resolution in general.

> For others,
> especially when there are no user-defined assignment operators in the
> target type, 'incompatible type' would be the better message.
There is always assignment operator in a class - implicit one. So no
viable operator= found probably is correct message even in this case.
Maybe it should print additional diagnostics - which assignment
operators are available (like it does for ambiguity) but that is
different question.

> What does it say for this:
>
> int i = hasNoConversionToInt();
>
> For this case, no viable overload would definitely be the wrong message.
Changes that I made only for the case when class instance on the left.
This one will work as before. I can actually put this as a test case
there as well.

Thanks,
Vyacheslav

Updated copy-assignment.cpp is attached
-------------- next part --------------
A non-text attachment was scrubbed...
Name: copy-assignment.cpp
Type: application/octet-stream
Size: 1610 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20090516/76fc29dc/attachment.obj>


More information about the cfe-dev mailing list