[LLVMbugs] [Bug 12646] New: -Wsign-compare fails to warn about mismatches involving const types

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Tue Apr 24 17:02:53 PDT 2012


http://llvm.org/bugs/show_bug.cgi?id=12646

             Bug #: 12646
           Summary: -Wsign-compare fails to warn about mismatches
                    involving const types
           Product: clang
           Version: trunk
          Platform: PC
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: fischman at chromium.org
                CC: dgregor at apple.com, llvmbugs at cs.uiuc.edu
    Classification: Unclassified


Compiling the following with [clang++ -Wsign-compare -c] (trunk 155352) results
in warnings for the first i==u comparison and then for all the comparisons in
g().  I believe the other comparisons in f() should also trigger the warning,
for consistency (but they appear not too, presumably because of the "const"s).

int f() {
  int i = 1;
  const int ci = 2;
  unsigned u = 3;
  const unsigned cu = 4;
  if (i == u) return 1;  // Only this triggers a warning!
  if (ci == cu) return 2;
  if (i == cu) return 3;
  if (ci == u) return 4;
  return 0;
}

int bar();
int g() {
  int i = bar();
  const int ci = bar();
  unsigned u = bar();
  const unsigned cu = bar();
  if (i == u) return 1;
  if (ci == cu) return 2;
  if (i == cu) return 3;
  if (ci == u) return 4;
  return 0;
}

-- 
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