[llvm-commits] [llvm] r41378 - in /llvm/trunk: include/llvm/ADT/APFloat.h lib/CodeGen/SelectionDAG/SelectionDAG.cpp lib/Support/APFloat.cpp lib/VMCore/Constants.cpp

Chris Lattner clattner at apple.com
Fri Aug 24 16:40:45 PDT 2007


On Aug 24, 2007, at 4:38 PM, Dale Johannesen wrote:

>
> On Aug 24, 2007, at 4:03 PM, Chris Lattner wrote:
>
>>>
>>> +    /* The definition of equality is not straightforward for
>>> floating point,
>>> +       so we won't use operator==.  Use one of the following, or
>>> write
>>> +       whatever it is you really mean. */
>>> +    bool operator==(const APFloat &) const;     // DO NOT IMPLEMENT
>>
>> Hey Dale,
>>
>> I think that you can just remove this and the compiler will give you
>> a compile-time error if you try to use it.  If you define it like
>> this, you just get a link-time error.
>
> Yep, and the linker error message doesn't tell you where the
> reference is coming from (I'm speaking from experience).  I mostly
> did it this way because I see about 40 other places it was done this
> way, and I  do see the utility as a statement of intent.  Why is this
> one different?

The difference here is that C++ compilers automatically synthesis  
copy ctors and default ctors and operator=, but they don't do the  
same for operator==.  To disable these automatically generated  
members, you have to "define" them, and put them in the private part  
of the class (so any users will get compile-time access violation  
errors as well as link errors).

-Chris



More information about the llvm-commits mailing list