llvm-project icon indicating copy to clipboard operation
llvm-project copied to clipboard

format string checker does not employ simple constant propagation

Open tkremenek opened this issue 18 years ago • 5 comments

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.

tkremenek avatar Dec 18 '07 20:12 tkremenek

mentioned in issue llvm/llvm-bugzilla-archive#3218

nunoplopes avatar Nov 26 '21 22:11 nunoplopes

This bug has been fixed for a while now. Closing.

tkremenek avatar Feb 27 '09 02:02 tkremenek

*** Bug llvm/llvm-bugzilla-archive#3218 has been marked as a duplicate of this bug. ***

nunoplopes avatar Dec 23 '08 00:12 nunoplopes

The new "Evaluate" logic may be able to do this.

lattner avatar Dec 18 '08 04:12 lattner

assigned to @tkremenek

tkremenek avatar Dec 18 '07 20:12 tkremenek