Skip to content

Commit 7f6fd34

Browse files
committed
C++: Expose a type resolution issue.
1 parent d23a3f8 commit 7f6fd34

File tree

3 files changed

+12
-6
lines changed

3 files changed

+12
-6
lines changed

cpp/ql/test/query-tests/Likely Bugs/Format/WrongTypeFormatArguments/Buildless/WrongTypeFormatArguments.expected

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
1+
| include_twice.h:8:19:8:19 | s | This format specifier for type 'size_t' does not match the argument type '..(*)(..)'. |
2+
| include_twice.h:9:19:9:19 | s | This format specifier for type 'size_t' does not match the argument type '..(*)(..)'. |
3+
| include_twice.h:10:18:10:18 | s | This format specifier for type 'int' does not match the argument type '..(*)(..)'. |
14
| include_twice.h:10:18:10:18 | s | This format specifier for type 'int' does not match the argument type 'unsigned long'. |
5+
| include_twice.h:11:19:11:19 | s | This format specifier for type 'long' does not match the argument type '..(*)(..)'. |
6+
| include_twice.h:12:20:12:20 | s | This format specifier for type 'long long' does not match the argument type '..(*)(..)'. |
7+
| include_twice.h:13:18:13:18 | s | This format specifier for type 'unsigned int' does not match the argument type '..(*)(..)'. |
28
| include_twice.h:13:18:13:18 | s | This format specifier for type 'unsigned int' does not match the argument type 'unsigned long'. |
39
| include_twice.h:21:18:21:39 | ... - ... | This format specifier for type 'int' does not match the argument type 'long'. |
410
| include_twice.h:21:18:21:39 | ... - ... | This format specifier for type 'int' does not match the argument type 'long'. |

cpp/ql/test/query-tests/Likely Bugs/Format/WrongTypeFormatArguments/Buildless/include_twice.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ void test_size_t() {
55

66
printf("%zd", s); // GOOD
77
printf("%zi", s); // GOOD
8-
printf("%zu", s); // GOOD
9-
printf("%zx", s); // GOOD
8+
printf("%zu", s); // GOOD [FALSE POSITIVE]
9+
printf("%zx", s); // GOOD [FALSE POSITIVE]
1010
printf("%d", s); // BAD
11-
printf("%ld", s); // BAD [NOT DETECTED]
12-
printf("%lld", s); // BAD [NOT DETECTED]
11+
printf("%ld", s); // BAD
12+
printf("%lld", s); // BAD
1313
printf("%u", s); // BAD
1414

1515
char buffer[1024];

cpp/ql/test/query-tests/Likely Bugs/Format/WrongTypeFormatArguments/Buildless/second.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
int printf(const char * format, ...);
44

5-
// defines type `myFunctionPointerType`
6-
typedef int (*myFunctionPointerType) ();
5+
// defines type `myFunctionPointerType`, referencing `size_t`
6+
typedef size_t (*myFunctionPointerType) ();
77

88
#include "include_twice.h"

0 commit comments

Comments
 (0)