C++: Identified another real-life FP

This commit is contained in:
Nora Dimitrijević
2022-09-28 21:19:45 +02:00
parent 96c73bcb19
commit 19a9c5d7d3

View File

@@ -13,6 +13,8 @@ struct X {
#define BAR(x, y) ((x), (y))
#define BAZ //printf
int test(int i, int j, int (*foo)(int), int (*bar)(int, int))
{
// Comma in simple if statement (prototypical example):
@@ -82,6 +84,9 @@ int test(int i, int j, int (*foo)(int), int (*bar)(int, int))
(void)sizeof(x.foo(i++), // GOOD? Unlikely to be misread
j++);
BAZ("%d %d\n", i,
j); // GOOD [FALSE POSITIVE] -- but can only be excluded by excluding all parenthesized commas (which sounds like a good idea actually)
// Comma in loops
while (i = foo(j++), // GOOD