Skip to content

Commit 19a9c5d

Browse files
committed
C++: Identified another real-life FP
1 parent 96c73bc commit 19a9c5d

File tree

1 file changed

+5
-0
lines changed
  • cpp/ql/test/query-tests/Best Practices/Likely Errors/CommaBeforeMisleadingIndentation

1 file changed

+5
-0
lines changed

cpp/ql/test/query-tests/Best Practices/Likely Errors/CommaBeforeMisleadingIndentation/test.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ struct X {
1313

1414
#define BAR(x, y) ((x), (y))
1515

16+
#define BAZ //printf
17+
1618
int test(int i, int j, int (*foo)(int), int (*bar)(int, int))
1719
{
1820
// Comma in simple if statement (prototypical example):
@@ -82,6 +84,9 @@ int test(int i, int j, int (*foo)(int), int (*bar)(int, int))
8284
(void)sizeof(x.foo(i++), // GOOD? Unlikely to be misread
8385
j++);
8486

87+
BAZ("%d %d\n", i,
88+
j); // GOOD [FALSE POSITIVE] -- but can only be excluded by excluding all parenthesized commas (which sounds like a good idea actually)
89+
8590
// Comma in loops
8691

8792
while (i = foo(j++), // GOOD

0 commit comments

Comments
 (0)