This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/59211] New: init_priority doesn't work with constant expressions
- From: "nyh at math dot technion.ac.il" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Wed, 20 Nov 2013 13:16:10 +0000
- Subject: [Bug c++/59211] New: init_priority doesn't work with constant expressions
- Auto-submitted: auto-generated
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!