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

Reply via email to