format string checker does not employ simple constant propagation
| Bugzilla Link | 1870 |
| Resolution | FIXED |
| Resolved on | Feb 26, 2009 18:02 |
| Version | unspecified |
| OS | All |
| CC | @tkremenek |
Extended Description
The following is a false positive (reported by Nico Weber) emitted by the format string checker:
s0539:src nico$ cat test.c #include "stdio.h"
int main() {
char buf[1];
sprintf(buf, 1 ? "" : "");
}
s0539:src nico$ ./clang test.c
running "/Users/nico/src/llvm-svn/Debug/bin/clang -fsyntax-only test.c"
test.c:5:16: warning: format string is not a string literal
(potentially insecure)
sprintf(buf, 1 ? "" : "");
1 diagnostic generated.
The false positive is a result of the checker not performing simple constant propagation of the string literal. Such expressions may be the result of macro expansion, and thus should be handled in order to suppress spurious warnings on correct code.
mentioned in issue llvm/llvm-bugzilla-archive#3218
This bug has been fixed for a while now. Closing.
*** Bug llvm/llvm-bugzilla-archive#3218 has been marked as a duplicate of this bug. ***
The new "Evaluate" logic may be able to do this.
assigned to @tkremenek