This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/37949] New: static initialisation through pointer deferred until run time
- From: "ajrobb at bigfoot dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 29 Oct 2008 10:25:42 -0000
- Subject: [Bug c++/37949] New: static initialisation through pointer deferred until run time
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
Given various methods for determining byte order on different platforms, the
following can be used in C++ to find the byte order across platforms.
static const uint32_t bytes = 0x03020100ul;
static const unsigned lo = *(const unsigned char*)&bytes;
Unfortunately, the value of 'lo' is determined at pre-run rather than at
compile time.
It would be useful if the compiler could determine the value of 'lo' so as to
eliminate constant logical tests and jumps.
--
Summary: static initialisation through pointer deferred until run
time
Product: gcc
Version: 4.2.4
Status: UNCONFIRMED
Severity: enhancement
Priority: P3
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: ajrobb at bigfoot dot com
GCC build triplet: i486-linux-gnu
GCC host triplet: i486-linux-gnu
GCC target triplet: i486-linux-gnu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37949