Skip to content

Commit ac63eb5

Browse files
Fix #14180 FN intToPointerCast with binary integer literal (#8643)
Co-authored-by: chrchr-github <noreply@github.com>
1 parent 22b3464 commit ac63eb5

2 files changed

Lines changed: 5 additions & 0 deletions

File tree

lib/checkother.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -464,6 +464,8 @@ void CheckOtherImpl::warningIntToPointerCast()
464464
format = "decimal";
465465
else if (MathLib::isOct(from->str()))
466466
format = "octal";
467+
else if (MathLib::isBin(from->str()))
468+
format = "binary";
467469
else
468470
continue;
469471
intToPointerCastError(tok, format);

test/testother.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2362,6 +2362,9 @@ class TestOther : public TestFixture {
23622362
checkIntToPointerCast("struct S { int i; };\n" // #13886, don't crash
23632363
"int f() { return sizeof(((struct S*)0)->i); }");
23642364
ASSERT_EQUALS("", errout_str());
2365+
2366+
checkIntToPointerCast("auto p = (int*)0b10;"); // #14180
2367+
ASSERT_EQUALS("[test.cpp:1:10]: (portability) Casting non-zero binary integer literal to pointer. [intToPointerCast]\n", errout_str());
23652368
}
23662369

23672370
struct CheckInvalidPointerCastOptions

0 commit comments

Comments
 (0)