Skip to content

bugprone-infinite-loop false positive with CATCH2 #44161

@pavelkryukov

Description

@pavelkryukov
Bugzilla Link 44816
Resolution FIXED
Resolved on Feb 17, 2020 04:50
Version unspecified
OS All
Depends On #44239
Blocks #43900
CC @EugeneZelenko,@zmodem,@VReichelt
Fixed by commit(s) rGc69ec6476806147e46bf09b693acb24177982dc2

Extended Description

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'

: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 { \ ^

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions