[Bug c/50459] New: alignof doesn't work on plain old constant, works with expressions containing it
b.r.longbons at gmail dot com
gcc-bugzilla@gcc.gnu.org
Tue Sep 20 05:20:00 GMT 2011
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50459
Bug #: 50459
Summary: alignof doesn't work on plain old constant, works with
expressions containing it
Classification: Unclassified
Product: gcc
Version: 4.6.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: b.r.longbons@gmail.com
For certain types of constant, the exact form:
__attribute__((aligned(align)))
fails, even though 'align' can be used in other constant expressions.
Types of constants that fail:
// C
enum { align = 8 };
// C++
const int align = 8;
class Foo { static const int align = 8; };
// and lots of nasty template stuff
Anything that forms an expression succeeds, even if it's just (align).
sizeof() or a C++11 constexpr function also work.
Bad versions: 4.2.4, 4.3.6, 4.4.6, 4.5.3, 4.6.0, 4.6.1, and a couple of recent
builds from git.
Minimal testcase:
enum { align = 8 };
int succeeds __attribute__((aligned((align)) ));
int fails __attribute__((aligned(align) ));
More information about the Gcc-bugs
mailing list