This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/59211] New: init_priority doesn't work with constant expressions


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

            Bug ID: 59211
           Summary: init_priority doesn't work with constant expressions
           Product: gcc
           Version: 4.8.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: nyh at math dot technion.ac.il

It seems that __attribute__((init_priority(...))) demands an integer constant,
and doesn't work with constant *expressions*. For example, the following
doesn't compile:

constexpr int prio = 123;
__attribute__((init_priority(prio))) t a;

Even more sadly for me, the following attempt to avoid manually defining
priority numbers doesn't compile:

enum class init_prio : int {
    first = 101,
    second,
    third,
};
__attribute__((init_priority(init_prio::second))) t a;

There is no real reason why this shouldn't be allowed. Interestingly, with
__attribute((constructor(...)), exactly the same constructs do work!


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]