[cfe-users] Wconstexpr-not-const on conversion operators

Mani monamimani at gmail.com
Wed Jun 12 19:42:00 PDT 2013


Hi all, 

There is a behaviour that I think is wrong about the Wconstexpr-not-const I don't think it should apply to conversion operators.

In my project I have warning as errors and the second operator have an error because it is not const, but actually marking it const will cause  an ambiguity. 

      constexpr operator const Vector3<T>() const
      {
         // It is the equivalent of Vector3 = Point3 - Origin
         return Vector3<T>(x, y, z);
      }

      constexpr operator Vector3<T>()
      {
         // It is the equivalent of Vector3 = Point3 - Origin
         return Vector3<T>(x, y, z);
      }

If I make it const here is the ambiguity:

error: reference initialization of type 'const Vector3<float> &' with initializer of type 'Math::Point3<Float32>' is ambiguous
               vertex.position_ = matrix * vertex.position_;
                                           ^~~~~~~~~~~~~~~~
note: candidate function
      constexpr operator const Vector3<T>() const
                ^
note: candidate function
      constexpr operator Vector3<T>() const

I know I could disable the warning locally but this condemn all people that will stay c++11 and not pass to c++1y.

Thanks for your feedback

Emmanuel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-users/attachments/20130612/9b90c6ee/attachment.html>


More information about the cfe-users mailing list