[llvm-bugs] [Bug 42090] New: Missed -Wsign-compare as compared to GCC9

via llvm-bugs llvm-bugs at lists.llvm.org
Fri May 31 03:13:26 PDT 2019


https://bugs.llvm.org/show_bug.cgi?id=42090

            Bug ID: 42090
           Summary: Missed -Wsign-compare as compared to GCC9
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Frontend
          Assignee: unassignedclangbugs at nondot.org
          Reporter: lebedev.ri at gmail.com
                CC: llvm-bugs at lists.llvm.org, neeilans at live.com,
                    richard-llvm at metafoo.co.uk

Manually reduced:

#include <cstdint>

struct S {
  int a;

  constexpr S();
  explicit constexpr S(int a_) : a(a_) {}
};

constexpr S b = S(12);

template <const S& e>
bool c(unsigned int d) {
  return d >= e.a;
}

bool test(unsigned int d);
bool test(unsigned int d) {
    return c<b>(d);
}

GCC diagnoses:
<source>: In instantiation of 'bool c(unsigned int) [with const S& e = b]':
<source>:19:18:   required from here
<source>:14:12: warning: comparison of integer expressions of different
signedness: 'unsigned int' and 'const int' [-Wsign-compare]
   14 |   return d >= e.a;
      |          ~~^~~~~~
Compiler returned: 0

clang doesn't.
https://godbolt.org/z/7xrWzz

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20190531/ae285c23/attachment.html>


More information about the llvm-bugs mailing list