This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c/31007] New: wrong 64bit constant calculation


#include <stdio.h>
#include <stdint.h>

int main()
{ 
  uint64_t ui4 = ~((1ULL << 63ULL) >> 3ULL);
  union {
   uint64_t i64;
   struct {
     uint32_t lo;
     uint32_t hi;
   } i32;
  } ui5;

  ui5.i64 = ui4;

  printf( "%llx %x\n", ui4, ui5.i32.hi );

  return 0;
}

Return efffffffffffffff efffffff
(instead of 7fffffffffffffff 7fffffff). Appropriate expression for 32bit
constant give expected result.


-- 
           Summary: wrong 64bit constant calculation
           Product: gcc
           Version: 4.1.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: hidden_peak at mail dot ru
 GCC build triplet: i686-pc-linux-gnu
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31007


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]