C++: Test for erroneous string types

This commit is contained in:
Calum Grant
2024-12-04 10:57:15 +00:00
parent cc4382c785
commit 19424020c3
2 changed files with 3 additions and 1 deletions

View File

@@ -1 +1,2 @@
| tests.c:7:18:7:18 | 1 | This format specifier for type 'char *' does not match the argument type 'int'. |
| tests.c:11:18:11:20 | str | This format specifier for type 'char *' does not match the argument type '<error-type> *'. |

View File

@@ -3,9 +3,10 @@
int printf(const char * format, ...);
int fprintf();
void f() {
void f(UNKNOWN_CHAR * str) {
printf("%s", 1); // BAD
printf("%s", implicit_function()); // GOOD - we should ignore the type
sprintf(0, "%s", ""); // GOOD
fprintf(0, "%s", ""); // GOOD
printf("%s", str); // GOOD - erroneous type is ignored
}