[LLVMbugs] [Bug 12463] New: -Wtautological-compare and -Wstring-compare are disabled if macro expansion is involved

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Thu Apr 5 07:55:42 PDT 2012


             Bug #: 12463
           Summary: -Wtautological-compare and -Wstring-compare are
                    disabled if macro expansion is involved
           Product: clang
           Version: trunk
          Platform: Other
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: -New Bugs
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: l.lunak at suse.cz
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

$ cat a.cpp
#define FOO "foo"
#define BAR "bar"
bool foo()
    bool b;
    b = FOO == BAR;
    b = "foo" == "bar";
    return b;
$ clang++ -Wall a.cpp -c
a.cpp:7:15: warning: result of comparison against a string literal is
unspecified (use strncmp instead) [-Wstring-compare]
    b = "foo" == "bar";
        ~~~~~ ^
1 warning generated.                                                            

Line 6 should generate a warning as well. As the warning says, the result of
such a comparison is unspecified, so it is never correct, even if it comes from
a macro expansion.

Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.

More information about the llvm-bugs mailing list