Issue 133257
Summary [C][Sema] -Wformat misleading idempotent FixItHint for scanning into const
Labels new issue
Assignees
Reporter whisperity
    The following code:

```c
#include <stdio.h>
#include <stdlib.h>

void parse(char* in) {
    const char* B = (char*) malloc(42);
    sscanf(in, "%s", B);
}
```

```
<source>:7:23: warning: format specifies type 'char *' but the argument has type 'const char *' [-Wformat]
    7 |     sscanf(pos, "%s", B);
      |                  ~~   ^
      | %s
```

https://godbolt.org/z/Gnqvq4Kvd

produces a `-Wformat` warning that has a `FixItHint` attached, which does not actually change anything related to the code. Such a warning is a problem in interactive editors where the editor shows "fix available", and after applying the fix, the warning is still there.

![Image](https://github.com/user-attachments/assets/28c8fbf7-6fdb-42d2-ac00-cae2ef31d509)
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to