[llvm-bugs] [Bug 38235] New: attribute((constructor)) accepts enum class as integer constan

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Jul 19 18:22:59 PDT 2018


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

            Bug ID: 38235
           Summary: attribute((constructor)) accepts enum class as integer
                    constan
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: C++
          Assignee: unassignedclangbugs at nondot.org
          Reporter: zhonghao at pku.org.cn
                CC: dgregor at apple.com, llvm-bugs at lists.llvm.org

The code is as follow:

enum class E : int { prio = 666 };
void f (int) __attribute__((constructor(E::prio)));

It is accepted by clang++ whereas the conversion should require an explicit
cast. default_conversion -> decay_conversion -> decl_constant_value_safe
returns:
<integer_cst 0x7ffff662efc0 type <enumeral_type 0x7ffff6624b28 E> constant 666>
and we then accept any integer_cst.

Instead, g++ rejects the code:


 error: constructor priorities must be integers from 0 to 65535 inclusive
 void f (int) __attribute__((constructor(E::prio)));
                                                  ^

-- 
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/20180720/9f66ec1f/attachment.html>


More information about the llvm-bugs mailing list