[llvm-bugs] [Bug 37979] New: incorrect sizeof for bitfield enum values

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Jun 28 12:15:29 PDT 2018


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

            Bug ID: 37979
           Summary: incorrect sizeof for bitfield enum values
           Product: clang
           Version: unspecified
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: C++
          Assignee: unassignedclangbugs at nondot.org
          Reporter: sbc at chromium.org
                CC: dgregor at apple.com, llvm-bugs at lists.llvm.org

Looks like this was broken by https://reviews.llvm.org/rL335781

The following test case is derived from one of the GCC torture tests:
https://github.com/gcc-mirror/gcc/blob/master/gcc/testsuite/g%2B%2B.dg/conversion/bitfield1.C

$ cat test.cc 
enum E { a, b = 1LL << 48 };

struct S {
  E e : 3;
};

S s;

int main () {
  static_assert(sizeof(E) == sizeof(long long));
  static_assert(sizeof(s.e + 3) == sizeof(long long));
}



$ ./bin/clang++ --std=c++17 -c test.cc
test.cc:11:3: error: static_assert failed
  static_assert(sizeof(s.e + 3) == sizeof(long long));
  ^             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.

-- 
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/20180628/c0bcd140/attachment.html>


More information about the llvm-bugs mailing list