[Bug c++/59211] New: init_priority doesn't work with constant expressions
nyh at math dot technion.ac.il
gcc-bugzilla@gcc.gnu.org
Wed Nov 20 13:16:00 GMT 2013
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!
More information about the Gcc-bugs
mailing list