bugprone-infinite-loop has a false positive for CATCH2 assertion macro. Example: https://godbolt.org/z/bzHeuz > #include <catch.hpp> > int foo(); > int bar(); > > TEST_CASE("Hello World") > { > int x = foo(); > int y = bar(); > CHECK( x < y); > } Output: > clang-tidy (trunk) #2 with x86-64 gcc 9.2 > -checks='*,-modernize-use-trailing-return-type' > <source>:10:5: warning: this loop is infinite; none of its condition variables (x, y) are updated in the loop body [bugprone-infinite-loop] > CHECK( x < y); > ^ > /opt/compiler-explorer/libs/catch2/v2.11.1/include/catch.hpp:217:22: note: expanded from macro 'CHECK' > #define CHECK( ... ) INTERNAL_CATCH_TEST( "CHECK", Catch::ResultDisposition::ContinueOnFailure, __VA_ARGS__ ) > ^ > /opt/compiler-explorer/libs/catch2/v2.11.1/include/internal/catch_capture.hpp:43:5: note: expanded from macro 'INTERNAL_CATCH_TEST' > do { \ > ^
The problematic loop is: > do { > > } while( (void)0, false && static_cast<bool>( !!(__VA_ARGS__) ) ) > // the expression here is never evaluated at runtime but it forces the compiler to give it a look
minimum reproducible test case ======================= void fail(bool a) { do { } while (false && a); } ======================= Should ignore loops with conditions that always eval to false
Fixed in https://reviews.llvm.org/rGc69ec6476806147e46bf09b693acb24177982dc2
Thanks! Could you please tell if it lands to LLVM 10?
(In reply to Pavel Kryukov from comment #4) > Thanks! Could you please tell if it lands to LLVM 10? It's necessary to create new merge request and make bug 44555 depended on it.
I’ve added the dependency - should I reopen the bug?
I've done it for you. But if it's not reopened it won't appear to block the release
(In reply to Nathan James from comment #3) > Fixed in https://reviews.llvm.org/rGc69ec6476806147e46bf09b693acb24177982dc2 Pushed to 10.x in 7a136d2768e26b30273f208fb3d64eae531c8455.
This probably caused bug 44894.