From 19bef86099f9a036a9fc94387772f39005b4e3d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludvig=20Gunne=20Lindstr=C3=B6m?= Date: Wed, 30 Oct 2024 09:20:07 +0100 Subject: [PATCH 1/7] fix #11685 --- lib/checktype.cpp | 24 ++++++++++++++++++++++++ test/testtype.cpp | 15 +++++++++++++++ 2 files changed, 39 insertions(+) diff --git a/lib/checktype.cpp b/lib/checktype.cpp index 9f3e0993868..f3477235078 100644 --- a/lib/checktype.cpp +++ b/lib/checktype.cpp @@ -432,9 +432,33 @@ void CheckType::checkFloatToIntegerOverflow() { logChecker("CheckType::checkFloatToIntegerOverflow"); + std::vector skippedTernaries; + for (const Token *tok = mTokenizer->tokens(); tok; tok = tok->next()) { const ValueType *vtint, *vtfloat; + if (!skippedTernaries.empty() && tok == skippedTernaries.back()) { + skippedTernaries.pop_back(); + while (tok && !Token::Match(tok, ";|)|}")) { + if (Token::simpleMatch(tok, "(")) { + tok = tok->link(); + } + tok = tok->next(); + } + } + + if (Token::simpleMatch(tok, "?")) { + const Token * condTok = tok->astOperand1(); + bool hasKnownIntValue = condTok->hasKnownIntValue(); + if (hasKnownIntValue || Token::Match(condTok, "true|false")) { + if ((hasKnownIntValue && condTok->getKnownIntValue()) || Token::simpleMatch(condTok, "true")) { + skippedTernaries.push_back(tok->astOperand2()); + } else { + tok = tok->astOperand2(); + } + } + } + // Explicit cast if (Token::Match(tok, "( %name%") && tok->astOperand1() && !tok->astOperand2()) { vtint = tok->valueType(); diff --git a/test/testtype.cpp b/test/testtype.cpp index 8d3f4acb421..43835c32594 100644 --- a/test/testtype.cpp +++ b/test/testtype.cpp @@ -495,6 +495,21 @@ class TestType : public TestFixture { " return 1234.5;\n" "}", settingsDefault); ASSERT_EQUALS("[test.cpp:2]: (error) Undefined behaviour: float () to integer conversion overflow.\n", removeFloat(errout_str())); + + const Settings settingsWithStdint = settingsBuilder().library("std.cfg").build(); + checkP("#define TEST(b, f) b ? 5000 : (uint16_t)f\n" // #11685 + "void f(void)\n" + "{\n" + " uint16_t u = TEST(true, 75000.0);\n" + "}\n", settingsWithStdint); + ASSERT_EQUALS("", errout_str()); + + checkP("#define TEST(b, f) b ? 5000 : (uint16_t)f\n" + "void f(void)\n" + "{\n" + " uint16_t u = TEST(false, 75000.0);\n" + "}\n", settingsWithStdint); + ASSERT_EQUALS("[test.cpp:4]: (error) Undefined behaviour: float () to integer conversion overflow.\n", removeFloat(errout_str())); } void integerOverflow() { // #11794 From 7e49fc23ba5b3a38848d2cdae3a91297139bd5d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludvig=20Gunne=20Lindstr=C3=B6m?= Date: Wed, 30 Oct 2024 15:16:49 +0100 Subject: [PATCH 2/7] Revert "fix #11685" This reverts commit 19bef86099f9a036a9fc94387772f39005b4e3d5. --- lib/checktype.cpp | 24 ------------------------ test/testtype.cpp | 15 --------------- 2 files changed, 39 deletions(-) diff --git a/lib/checktype.cpp b/lib/checktype.cpp index f3477235078..9f3e0993868 100644 --- a/lib/checktype.cpp +++ b/lib/checktype.cpp @@ -432,33 +432,9 @@ void CheckType::checkFloatToIntegerOverflow() { logChecker("CheckType::checkFloatToIntegerOverflow"); - std::vector skippedTernaries; - for (const Token *tok = mTokenizer->tokens(); tok; tok = tok->next()) { const ValueType *vtint, *vtfloat; - if (!skippedTernaries.empty() && tok == skippedTernaries.back()) { - skippedTernaries.pop_back(); - while (tok && !Token::Match(tok, ";|)|}")) { - if (Token::simpleMatch(tok, "(")) { - tok = tok->link(); - } - tok = tok->next(); - } - } - - if (Token::simpleMatch(tok, "?")) { - const Token * condTok = tok->astOperand1(); - bool hasKnownIntValue = condTok->hasKnownIntValue(); - if (hasKnownIntValue || Token::Match(condTok, "true|false")) { - if ((hasKnownIntValue && condTok->getKnownIntValue()) || Token::simpleMatch(condTok, "true")) { - skippedTernaries.push_back(tok->astOperand2()); - } else { - tok = tok->astOperand2(); - } - } - } - // Explicit cast if (Token::Match(tok, "( %name%") && tok->astOperand1() && !tok->astOperand2()) { vtint = tok->valueType(); diff --git a/test/testtype.cpp b/test/testtype.cpp index 43835c32594..8d3f4acb421 100644 --- a/test/testtype.cpp +++ b/test/testtype.cpp @@ -495,21 +495,6 @@ class TestType : public TestFixture { " return 1234.5;\n" "}", settingsDefault); ASSERT_EQUALS("[test.cpp:2]: (error) Undefined behaviour: float () to integer conversion overflow.\n", removeFloat(errout_str())); - - const Settings settingsWithStdint = settingsBuilder().library("std.cfg").build(); - checkP("#define TEST(b, f) b ? 5000 : (uint16_t)f\n" // #11685 - "void f(void)\n" - "{\n" - " uint16_t u = TEST(true, 75000.0);\n" - "}\n", settingsWithStdint); - ASSERT_EQUALS("", errout_str()); - - checkP("#define TEST(b, f) b ? 5000 : (uint16_t)f\n" - "void f(void)\n" - "{\n" - " uint16_t u = TEST(false, 75000.0);\n" - "}\n", settingsWithStdint); - ASSERT_EQUALS("[test.cpp:4]: (error) Undefined behaviour: float () to integer conversion overflow.\n", removeFloat(errout_str())); } void integerOverflow() { // #11794 From d16d5a41ef2ac92c9ad3c9a4eea48527ea180781 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludvig=20Gunne=20Lindstr=C3=B6m?= Date: Wed, 30 Oct 2024 16:15:39 +0100 Subject: [PATCH 3/7] fix #11685, add isUnreachableOperand --- lib/astutils.cpp | 46 ++++++++++++++++++++++++++++++++++++++++++++++ lib/astutils.h | 2 ++ lib/checktype.cpp | 7 +++++++ test/testtype.cpp | 40 ++++++++++++++++++++++++++++++++++++++++ 4 files changed, 95 insertions(+) diff --git a/lib/astutils.cpp b/lib/astutils.cpp index 4fae5b39b79..16f0647b7bb 100644 --- a/lib/astutils.cpp +++ b/lib/astutils.cpp @@ -3725,3 +3725,49 @@ bool isExhaustiveSwitch(const Token *startbrace) return false; } + +template +static bool isKnownOrLiteral(const Token *tok, T value); + +template<> +bool isKnownOrLiteral(const Token *tok, bool value) +{ + return (tok->hasKnownIntValue() && static_cast(tok->getKnownIntValue()) == value) + || (value && Token::simpleMatch(tok, "true")) + || (!value && Token::simpleMatch(tok, "false")); +} + +bool isUnreachableOperand(const Token *tok) +{ + for (;;) + { + const Token *parent = tok->astParent(); + if (!parent) + break; + + if (parent->isBinaryOp()) { + bool left = tok == parent->astOperand1(); + const Token *sibling = left ? parent->astOperand2() : parent->astOperand1(); + + // logical and + if (Token::simpleMatch(parent, "&&") && !left && isKnownOrLiteral(sibling, false)) + return true; + + // logical or + if (Token::simpleMatch(parent, "||") && !left && isKnownOrLiteral(sibling, true)) + return true; + + // ternary + if (Token::simpleMatch(parent, ":") && Token::simpleMatch(parent->astParent(), "?")) { + const Token *condTok = parent->astParent()->astOperand1(); + if ((isKnownOrLiteral(condTok, true) && !left) + || (isKnownOrLiteral(condTok, false) && left)) + return true; + } + } + + tok = parent; + } + + return false; +} diff --git a/lib/astutils.h b/lib/astutils.h index 5767786445a..f5ffc67da1b 100644 --- a/lib/astutils.h +++ b/lib/astutils.h @@ -448,4 +448,6 @@ bool isUnevaluated(const Token *tok); bool isExhaustiveSwitch(const Token *startbrace); +bool isUnreachableOperand(const Token *tok); + #endif // astutilsH diff --git a/lib/checktype.cpp b/lib/checktype.cpp index 9f3e0993868..5fc65b9a7c8 100644 --- a/lib/checktype.cpp +++ b/lib/checktype.cpp @@ -20,6 +20,7 @@ //--------------------------------------------------------------------------- #include "checktype.h" +#include "astutils.h" #include "errortypes.h" #include "mathlib.h" #include "platform.h" @@ -437,6 +438,8 @@ void CheckType::checkFloatToIntegerOverflow() // Explicit cast if (Token::Match(tok, "( %name%") && tok->astOperand1() && !tok->astOperand2()) { + if (isUnreachableOperand(tok)) + continue; vtint = tok->valueType(); vtfloat = tok->astOperand1()->valueType(); checkFloatToIntegerOverflow(tok, vtint, vtfloat, tok->astOperand1()->values()); @@ -444,12 +447,16 @@ void CheckType::checkFloatToIntegerOverflow() // Assignment else if (tok->str() == "=" && tok->astOperand1() && tok->astOperand2()) { + if (isUnreachableOperand(tok)) + continue; vtint = tok->astOperand1()->valueType(); vtfloat = tok->astOperand2()->valueType(); checkFloatToIntegerOverflow(tok, vtint, vtfloat, tok->astOperand2()->values()); } else if (tok->str() == "return" && tok->astOperand1() && tok->astOperand1()->valueType() && tok->astOperand1()->valueType()->isFloat()) { + if (isUnreachableOperand(tok)) + continue; const Scope *scope = tok->scope(); while (scope && scope->type != Scope::ScopeType::eLambda && scope->type != Scope::ScopeType::eFunction) scope = scope->nestedIn; diff --git a/test/testtype.cpp b/test/testtype.cpp index 8d3f4acb421..cc40b2c4c9e 100644 --- a/test/testtype.cpp +++ b/test/testtype.cpp @@ -495,6 +495,46 @@ class TestType : public TestFixture { " return 1234.5;\n" "}", settingsDefault); ASSERT_EQUALS("[test.cpp:2]: (error) Undefined behaviour: float () to integer conversion overflow.\n", removeFloat(errout_str())); + + const Settings settingsWithStdint = settingsBuilder().library("std.cfg").build(); + + checkP("#define TEST(b, f) b ? 5000 : (uint16_t)f\n" // #11685 + "void f()\n" + "{\n" + " uint16_t u = TEST(true, 75000.0);\n" + "}\n", settingsWithStdint); + ASSERT_EQUALS("", errout_str()); + + checkP("#define TEST(b, f) b ? 5000 : (uint16_t)f\n" + "void f()\n" + "{\n" + " uint16_t u = TEST(false, 75000.0);\n" + "}\n", settingsWithStdint); + ASSERT_EQUALS("[test.cpp:4]: (error) Undefined behaviour: float () to integer conversion overflow.\n", removeFloat(errout_str())); + + check( "bool f(uint16_t x);\n" + "bool g() {\n" + " return false && f((uint16_t)75000.0);\n" + "}\n", settingsWithStdint); + ASSERT_EQUALS("", errout_str()); + + check( "bool f(uint16_t x);\n" + "bool g() {\n" + " return true && f((uint16_t)75000.0);\n" + "}\n", settingsWithStdint); + ASSERT_EQUALS("[test.cpp:3]: (error) Undefined behaviour: float () to integer conversion overflow.\n", removeFloat(errout_str())); + + check( "bool f(uint16_t x);\n" + "bool g() {\n" + " return true || f((uint16_t)75000.0);\n" + "}\n", settingsWithStdint); + ASSERT_EQUALS("", errout_str()); + + check( "bool f(uint16_t x);\n" + "bool g() {\n" + " return false || f((uint16_t)75000.0);\n" + "}\n", settingsWithStdint); + ASSERT_EQUALS("[test.cpp:3]: (error) Undefined behaviour: float () to integer conversion overflow.\n", removeFloat(errout_str())); } void integerOverflow() { // #11794 From 76a1d5d4334b370d182aa0ba79af5475a640fb5d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludvig=20Gunne=20Lindstr=C3=B6m?= Date: Wed, 30 Oct 2024 17:31:20 +0100 Subject: [PATCH 4/7] don't match bool literal --- lib/astutils.cpp | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/lib/astutils.cpp b/lib/astutils.cpp index 16f0647b7bb..41ebf7f4cef 100644 --- a/lib/astutils.cpp +++ b/lib/astutils.cpp @@ -3726,17 +3726,6 @@ bool isExhaustiveSwitch(const Token *startbrace) return false; } -template -static bool isKnownOrLiteral(const Token *tok, T value); - -template<> -bool isKnownOrLiteral(const Token *tok, bool value) -{ - return (tok->hasKnownIntValue() && static_cast(tok->getKnownIntValue()) == value) - || (value && Token::simpleMatch(tok, "true")) - || (!value && Token::simpleMatch(tok, "false")); -} - bool isUnreachableOperand(const Token *tok) { for (;;) @@ -3750,18 +3739,19 @@ bool isUnreachableOperand(const Token *tok) const Token *sibling = left ? parent->astOperand2() : parent->astOperand1(); // logical and - if (Token::simpleMatch(parent, "&&") && !left && isKnownOrLiteral(sibling, false)) + if (Token::simpleMatch(parent, "&&") && !left && sibling->hasKnownIntValue() + && !sibling->getKnownIntValue()) return true; // logical or - if (Token::simpleMatch(parent, "||") && !left && isKnownOrLiteral(sibling, true)) + if (Token::simpleMatch(parent, "||") && !left && sibling->hasKnownIntValue() + && sibling->getKnownIntValue()) return true; // ternary if (Token::simpleMatch(parent, ":") && Token::simpleMatch(parent->astParent(), "?")) { const Token *condTok = parent->astParent()->astOperand1(); - if ((isKnownOrLiteral(condTok, true) && !left) - || (isKnownOrLiteral(condTok, false) && left)) + if (condTok->hasKnownIntValue() && static_cast(condTok->getKnownIntValue()) != left) return true; } } From 091bc91826ca5205f09a37a528f3021b2dcdf71b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludvig=20Gunne=20Lindstr=C3=B6m?= Date: Sat, 2 Nov 2024 21:45:17 +0100 Subject: [PATCH 5/7] update Makefile --- Makefile | 2 +- oss-fuzz/Makefile | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index ff990d696ae..8bfa89287a7 100644 --- a/Makefile +++ b/Makefile @@ -572,7 +572,7 @@ $(libcppdir)/checkstl.o: lib/checkstl.cpp lib/addoninfo.h lib/astutils.h lib/che $(libcppdir)/checkstring.o: lib/checkstring.cpp lib/addoninfo.h lib/astutils.h lib/check.h lib/checkstring.h lib/config.h lib/errortypes.h lib/library.h lib/mathlib.h lib/platform.h lib/settings.h lib/smallvector.h lib/sourcelocation.h lib/standards.h lib/suppressions.h lib/symboldatabase.h lib/templatesimplifier.h lib/token.h lib/tokenize.h lib/tokenlist.h lib/utils.h lib/vfvalue.h $(CXX) ${INCLUDE_FOR_LIB} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $(libcppdir)/checkstring.cpp -$(libcppdir)/checktype.o: lib/checktype.cpp lib/addoninfo.h lib/check.h lib/checktype.h lib/config.h lib/errortypes.h lib/library.h lib/mathlib.h lib/platform.h lib/settings.h lib/sourcelocation.h lib/standards.h lib/suppressions.h lib/symboldatabase.h lib/templatesimplifier.h lib/token.h lib/tokenize.h lib/tokenlist.h lib/utils.h lib/valueflow.h lib/vfvalue.h +$(libcppdir)/checktype.o: lib/checktype.cpp lib/addoninfo.h lib/astutils.h lib/check.h lib/checktype.h lib/config.h lib/errortypes.h lib/library.h lib/mathlib.h lib/platform.h lib/settings.h lib/smallvector.h lib/sourcelocation.h lib/standards.h lib/suppressions.h lib/symboldatabase.h lib/templatesimplifier.h lib/token.h lib/tokenize.h lib/tokenlist.h lib/utils.h lib/valueflow.h lib/vfvalue.h $(CXX) ${INCLUDE_FOR_LIB} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $(libcppdir)/checktype.cpp $(libcppdir)/checkuninitvar.o: lib/checkuninitvar.cpp lib/addoninfo.h lib/astutils.h lib/check.h lib/checknullpointer.h lib/checkuninitvar.h lib/color.h lib/config.h lib/ctu.h lib/errorlogger.h lib/errortypes.h lib/library.h lib/mathlib.h lib/platform.h lib/settings.h lib/smallvector.h lib/sourcelocation.h lib/standards.h lib/suppressions.h lib/symboldatabase.h lib/templatesimplifier.h lib/token.h lib/tokenize.h lib/tokenlist.h lib/utils.h lib/vfvalue.h diff --git a/oss-fuzz/Makefile b/oss-fuzz/Makefile index 65ab189ffce..a9e1b8b7e6a 100644 --- a/oss-fuzz/Makefile +++ b/oss-fuzz/Makefile @@ -259,7 +259,7 @@ $(libcppdir)/checkstl.o: ../lib/checkstl.cpp ../lib/addoninfo.h ../lib/astutils. $(libcppdir)/checkstring.o: ../lib/checkstring.cpp ../lib/addoninfo.h ../lib/astutils.h ../lib/check.h ../lib/checkstring.h ../lib/config.h ../lib/errortypes.h ../lib/library.h ../lib/mathlib.h ../lib/platform.h ../lib/settings.h ../lib/smallvector.h ../lib/sourcelocation.h ../lib/standards.h ../lib/suppressions.h ../lib/symboldatabase.h ../lib/templatesimplifier.h ../lib/token.h ../lib/tokenize.h ../lib/tokenlist.h ../lib/utils.h ../lib/vfvalue.h $(CXX) ${LIB_FUZZING_ENGINE} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $(libcppdir)/checkstring.cpp -$(libcppdir)/checktype.o: ../lib/checktype.cpp ../lib/addoninfo.h ../lib/check.h ../lib/checktype.h ../lib/config.h ../lib/errortypes.h ../lib/library.h ../lib/mathlib.h ../lib/platform.h ../lib/settings.h ../lib/sourcelocation.h ../lib/standards.h ../lib/suppressions.h ../lib/symboldatabase.h ../lib/templatesimplifier.h ../lib/token.h ../lib/tokenize.h ../lib/tokenlist.h ../lib/utils.h ../lib/valueflow.h ../lib/vfvalue.h +$(libcppdir)/checktype.o: ../lib/checktype.cpp ../lib/addoninfo.h ../lib/astutils.h ../lib/check.h ../lib/checktype.h ../lib/config.h ../lib/errortypes.h ../lib/library.h ../lib/mathlib.h ../lib/platform.h ../lib/settings.h ../lib/smallvector.h ../lib/sourcelocation.h ../lib/standards.h ../lib/suppressions.h ../lib/symboldatabase.h ../lib/templatesimplifier.h ../lib/token.h ../lib/tokenize.h ../lib/tokenlist.h ../lib/utils.h ../lib/valueflow.h ../lib/vfvalue.h $(CXX) ${LIB_FUZZING_ENGINE} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $(libcppdir)/checktype.cpp $(libcppdir)/checkuninitvar.o: ../lib/checkuninitvar.cpp ../lib/addoninfo.h ../lib/astutils.h ../lib/check.h ../lib/checknullpointer.h ../lib/checkuninitvar.h ../lib/color.h ../lib/config.h ../lib/ctu.h ../lib/errorlogger.h ../lib/errortypes.h ../lib/library.h ../lib/mathlib.h ../lib/platform.h ../lib/settings.h ../lib/smallvector.h ../lib/sourcelocation.h ../lib/standards.h ../lib/suppressions.h ../lib/symboldatabase.h ../lib/templatesimplifier.h ../lib/token.h ../lib/tokenize.h ../lib/tokenlist.h ../lib/utils.h ../lib/vfvalue.h From 19036fde1a484007828e7b13ec0906b6eef62402 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludvig=20Gunne=20Lindstr=C3=B6m?= Date: Sun, 3 Nov 2024 16:39:49 +0100 Subject: [PATCH 6/7] add const --- lib/astutils.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/astutils.cpp b/lib/astutils.cpp index 41ebf7f4cef..a762d500505 100644 --- a/lib/astutils.cpp +++ b/lib/astutils.cpp @@ -3735,7 +3735,7 @@ bool isUnreachableOperand(const Token *tok) break; if (parent->isBinaryOp()) { - bool left = tok == parent->astOperand1(); + const bool left = tok == parent->astOperand1(); const Token *sibling = left ? parent->astOperand2() : parent->astOperand1(); // logical and From 7be677f2f407245f73115cac0e01ecab78102411 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludvig=20Gunne=20Lindstr=C3=B6m?= Date: Sun, 3 Nov 2024 21:41:15 +0100 Subject: [PATCH 7/7] avoid loading std.cfg --- test/testtype.cpp | 38 ++++++++++++++++++-------------------- 1 file changed, 18 insertions(+), 20 deletions(-) diff --git a/test/testtype.cpp b/test/testtype.cpp index cc40b2c4c9e..f40cd4c0652 100644 --- a/test/testtype.cpp +++ b/test/testtype.cpp @@ -496,44 +496,42 @@ class TestType : public TestFixture { "}", settingsDefault); ASSERT_EQUALS("[test.cpp:2]: (error) Undefined behaviour: float () to integer conversion overflow.\n", removeFloat(errout_str())); - const Settings settingsWithStdint = settingsBuilder().library("std.cfg").build(); - - checkP("#define TEST(b, f) b ? 5000 : (uint16_t)f\n" // #11685 + checkP("#define TEST(b, f) b ? 5000 : (unsigned short)f\n" // #11685 "void f()\n" "{\n" - " uint16_t u = TEST(true, 75000.0);\n" - "}\n", settingsWithStdint); + " unsigned short u = TEST(true, 75000.0);\n" + "}\n", settingsDefault); ASSERT_EQUALS("", errout_str()); - checkP("#define TEST(b, f) b ? 5000 : (uint16_t)f\n" + checkP("#define TEST(b, f) b ? 5000 : (unsigned short)f\n" "void f()\n" "{\n" - " uint16_t u = TEST(false, 75000.0);\n" - "}\n", settingsWithStdint); + " unsigned short u = TEST(false, 75000.0);\n" + "}\n", settingsDefault); ASSERT_EQUALS("[test.cpp:4]: (error) Undefined behaviour: float () to integer conversion overflow.\n", removeFloat(errout_str())); - check( "bool f(uint16_t x);\n" + check( "bool f(unsigned short x);\n" "bool g() {\n" - " return false && f((uint16_t)75000.0);\n" - "}\n", settingsWithStdint); + " return false && f((unsigned short)75000.0);\n" + "}\n", settingsDefault); ASSERT_EQUALS("", errout_str()); - check( "bool f(uint16_t x);\n" + check( "bool f(unsigned short x);\n" "bool g() {\n" - " return true && f((uint16_t)75000.0);\n" - "}\n", settingsWithStdint); + " return true && f((unsigned short)75000.0);\n" + "}\n", settingsDefault); ASSERT_EQUALS("[test.cpp:3]: (error) Undefined behaviour: float () to integer conversion overflow.\n", removeFloat(errout_str())); - check( "bool f(uint16_t x);\n" + check( "bool f(unsigned short x);\n" "bool g() {\n" - " return true || f((uint16_t)75000.0);\n" - "}\n", settingsWithStdint); + " return true || f((unsigned short)75000.0);\n" + "}\n", settingsDefault); ASSERT_EQUALS("", errout_str()); - check( "bool f(uint16_t x);\n" + check( "bool f(unsigned short x);\n" "bool g() {\n" - " return false || f((uint16_t)75000.0);\n" - "}\n", settingsWithStdint); + " return false || f((unsigned short)75000.0);\n" + "}\n", settingsDefault); ASSERT_EQUALS("[test.cpp:3]: (error) Undefined behaviour: float () to integer conversion overflow.\n", removeFloat(errout_str())); }