[PATCH] D98416: [clang-tidy] Fix cppcoreguidelines-narrowing-conversions false positive

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Mar 15 06:05:34 PDT 2021


aaron.ballman added a comment.
Herald added a project: clang-tools-extra.

> However this has opened a can of worms. Currenty float a = std::numeric_limits<double>::infinity(); is marked as narrowing.

I think this is technically not narrowing, per http://eel.is/c++draft/dcl.init.list#7.2, because the source is a constant expression (at least, after C++11) and the value can be represented after conversion. However, I wonder if the same is true for the various NaNs as it is for infinity?

> Whats more suspicious is double a = std::numeric_limits<float>::infinity(); is also marked as narrowing.

This is definitely not narrowing.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D98416/new/

https://reviews.llvm.org/D98416



More information about the cfe-commits mailing list