Skip to content

Commit fe85e00

Browse files
committed
C++: Add test for cpp/wrong-type-format-argument
1 parent 886c7f1 commit fe85e00

File tree

3 files changed

+16
-0
lines changed

3 files changed

+16
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
| tests.c:7:18:7:18 | 1 | This format specifier for type 'char *' does not match the argument type 'int'. |
2+
| tests.c:8:18:8:34 | call to implicit_function | This format specifier for type 'char *' does not match the argument type 'int'. |
3+
| tests.c:9:13:9:13 | 0 | This format specifier for type 'char *' does not match the argument type 'int'. |
4+
| tests.c:10:13:10:13 | 0 | This format specifier for type 'char *' does not match the argument type 'int'. |
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Likely Bugs/Format/WrongTypeFormatArguments.ql
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// semmle-extractor-options: --expect_errors
2+
3+
int printf(const char * format, ...);
4+
int fprintf();
5+
6+
int f() {
7+
printf("%s", 1); // BAD - TP
8+
printf("%s", implicit_function()); // BAD (FP) - we should not infer the return type
9+
sprintf(0, "%s", ""); // BAD (FP)
10+
fprintf(0, "%s", ""); // BAD (FP)
11+
}

0 commit comments

Comments
 (0)