[PATCH] D33470: [clang-tidy] Add misc-default-numerics
Piotr Padlewski via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue May 23 15:41:04 PDT 2017
Prazek created this revision.
Herald added subscribers: xazax.hun, mgorny.
This check flags usages of ``std::numeric_limits<T>::{min,max}()`` for
unspecialized types. It is dangerous because returns T(), which might is
rarely
minimum or maximum for this type.
Consider scenario:
1. Have `typedef long long BigInt` in source code
2. Use `std::numeric_limits<BigInt>::min()`
3. Replace the `BigInt` typedef with class implementing BigIntegers
4. Compile silently your code and find it few years later that you have
of by
9223372036854775808 error.
https://reviews.llvm.org/D33470
Files:
clang-tidy/misc/CMakeLists.txt
clang-tidy/misc/DefaultNumericsCheck.cpp
clang-tidy/misc/DefaultNumericsCheck.h
clang-tidy/misc/MiscTidyModule.cpp
docs/ReleaseNotes.rst
docs/clang-tidy/checks/list.rst
docs/clang-tidy/checks/misc-default-numerics.rst
test/clang-tidy/misc-default-numerics.cpp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D33470.100015.patch
Type: text/x-patch
Size: 7633 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170523/6890e21d/attachment.bin>
More information about the cfe-commits
mailing list