[PATCH] Don't warn about floating point comparison in unevaluated contexts

Ondřej Majerech majerech.o at gmail.com
Sat Jan 24 11:06:15 PST 2015


Testcase:

int
main() {
   double x = 1.0, y = 2.0;
   decltype(x == y) b{};
   (void) b;
}

With current Clang, the code above produces a warning:

/tmp/foo.cpp:4:14: warning: comparing floating point with == or != is unsafe
       [-Wfloat-equal]
   decltype(x == y) b{};

That warning is clearly useless as we are in an unevaluated context 
here. This patch suppresses this warning in these contexts.

There is no test for this patch, because I couldn't find any suitable 
test file to add it to. I'll be happy to add one if you can suggest a 
proper place for it.

~ Ondra
-------------- next part --------------
A non-text attachment was scrubbed...
Name: wfloat-equal-in-unevaluated-ctx.patch
Type: text/x-patch
Size: 579 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20150124/f18850d8/attachment.bin>


More information about the cfe-commits mailing list