<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - attribute((constructor)) accepts enum class as integer constan"
   href="https://bugs.llvm.org/show_bug.cgi?id=38235">38235</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>attribute((constructor)) accepts enum class as integer constan
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>enhancement
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>C++
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>zhonghao@pku.org.cn
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>dgregor@apple.com, llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>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)));
                                                  ^</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>