diff --git a/lib/checkother.cpp b/lib/checkother.cpp index b5fd0dda361..801dc529568 100644 --- a/lib/checkother.cpp +++ b/lib/checkother.cpp @@ -464,6 +464,8 @@ void CheckOtherImpl::warningIntToPointerCast() format = "decimal"; else if (MathLib::isOct(from->str())) format = "octal"; + else if (MathLib::isBin(from->str())) + format = "binary"; else continue; intToPointerCastError(tok, format); diff --git a/test/testother.cpp b/test/testother.cpp index 93e67229f43..73f10cbe76e 100644 --- a/test/testother.cpp +++ b/test/testother.cpp @@ -2362,6 +2362,9 @@ class TestOther : public TestFixture { checkIntToPointerCast("struct S { int i; };\n" // #13886, don't crash "int f() { return sizeof(((struct S*)0)->i); }"); ASSERT_EQUALS("", errout_str()); + + checkIntToPointerCast("auto p = (int*)0b10;"); // #14180 + ASSERT_EQUALS("[test.cpp:1:10]: (portability) Casting non-zero binary integer literal to pointer. [intToPointerCast]\n", errout_str()); } struct CheckInvalidPointerCastOptions