[Bug c++/59281] New: attribute((constructor)) accepts enum class as integer constant

glisse at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Sun Nov 24 23:12:00 GMT 2013


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59281

            Bug ID: 59281
           Summary: attribute((constructor)) accepts enum class as integer
                    constant
           Product: gcc
           Version: 4.9.0
            Status: UNCONFIRMED
          Keywords: accepts-invalid
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: glisse at gcc dot gnu.org

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

is accepted with -std=c++11 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.

The example comes from PR 59211.



More information about the Gcc-bugs mailing list