[llvm-bugs] [Bug 40977] New: Wrong static_assert on type of underlying_type<memory_order>

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Mar 6 07:14:41 PST 2019


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

            Bug ID: 40977
           Summary: Wrong static_assert on type of
                    underlying_type<memory_order>
           Product: libc++
           Version: unspecified
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: release blocker
          Priority: P
         Component: All Bugs
          Assignee: davide at freebsd.org
          Reporter: diogo.sampaio at arm.com
                CC: llvm-bugs at lists.llvm.org, mclow.lists at gmail.com

Created attachment 21570
  --> https://bugs.llvm.org/attachment.cgi?id=21570&action=edit
Small reproducer

In the file include/atomic

typedef enum memory_order {
  memory_order_relaxed, memory_order_consume, memory_order_acquire,
  memory_order_release, memory_order_acq_rel, memory_order_seq_cst
} memory_order;

static_assert((is_same<underlying_type<memory_order>::type,
unsigned>::value), "Underlying type differs from unsigned unexpectedly");

when compiling with "g++ -std=c++11 -fshort-enums"
the underlying type reduces to unsigned char, and the assert fails.

--
A quick fix would be set the last value to something that won't fit in a
uchar...

memory_order_seq_cst = 0xFFFFFFFF

-- 
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/20190306/acce4872/attachment.html>


More information about the llvm-bugs mailing list