From 390758e1c47b359c0f443a7a5a744952c7065da7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Thu, 20 Jun 2024 16:21:59 +0200 Subject: [PATCH] Fixed #12862 (std.cfg: std::is.. functions returns bool) --- cfg/std.cfg | 74 ++++++++++++++++++++++++++++++++++++++++-------- test/cfg/std.cpp | 26 ++++++++++++++++- 2 files changed, 87 insertions(+), 13 deletions(-) diff --git a/cfg/std.cfg b/cfg/std.cfg index 774e4dbf1c7d..8af76755bb35 100644 --- a/cfg/std.cfg +++ b/cfg/std.cfg @@ -3318,11 +3318,7 @@ The obsolete function 'gets' is called. With 'gets' you'll get a buffer overrun - - - - - + @@ -3333,8 +3329,23 @@ The obsolete function 'gets' is called. With 'gets' you'll get a buffer overrun + + + + + + + + + false + + + + + + - + arg1>arg2?1:0 @@ -3347,8 +3358,22 @@ The obsolete function 'gets' is called. With 'gets' you'll get a buffer overrun + + + + + arg1>arg2?1:0 + false + + + + + + + + - + arg1 >= arg2?1:0 @@ -3361,12 +3386,22 @@ The obsolete function 'gets' is called. With 'gets' you'll get a buffer overrun + + + + + arg1 >= arg2?1:0 + false + + + + + + + + - - - - - + @@ -3377,6 +3412,21 @@ The obsolete function 'gets' is called. With 'gets' you'll get a buffer overrun + + + + + + + + + false + + + + + + diff --git a/test/cfg/std.cpp b/test/cfg/std.cpp index 627d2d68bbc7..736e67fc48a2 100644 --- a/test/cfg/std.cpp +++ b/test/cfg/std.cpp @@ -2685,6 +2685,12 @@ void uninitvar_fpclassify(void) (void)std::fpclassify(ld); } +void bool_isfinite(float f) +{ + // cppcheck-suppress compareBoolExpressionWithInt + if (std::isfinite(f)==123) {} +} + void uninitvar_isfinite(void) { float f; @@ -2700,6 +2706,12 @@ void uninitvar_isfinite(void) (void)std::isfinite(ld); } +void bool_isgreater(float f) +{ + // cppcheck-suppress compareBoolExpressionWithInt + if (std::isgreater(f)==123) {} +} + void uninitvar_isgreater(void) { float f1,f2; @@ -2715,6 +2727,12 @@ void uninitvar_isgreater(void) (void)std::isgreater(ld1,ld2); } +void bool_isgreaterequal(float f) +{ + // cppcheck-suppress compareBoolExpressionWithInt + if (std::isgreaterequal(f)==123) {} +} + void uninitvar_isgreaterequal(void) { float f1,f2; @@ -2730,6 +2748,12 @@ void uninitvar_isgreaterequal(void) (void)std::isgreaterequal(ld1,ld2); } +void bool_isinf(float f) +{ + // cppcheck-suppress compareBoolExpressionWithInt + if (std::isinf(f)==123) {} +} + void uninitvar_isinf(void) { double d; @@ -5085,4 +5109,4 @@ void constParameterReference_assign(std::vector& v, int& r) { void constParameterReference_insert(std::list& l, int& r) { l.insert(l.end(), r); l.insert(l.end(), 5, r); -} \ No newline at end of file +}