[Bug target/56351] ARM Big-Endian: storing local double to packed variable causes corruption

sethml at google dot com gcc-bugzilla@gcc.gnu.org
Fri Feb 15 20:17:00 GMT 2013


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

--- Comment #1 from Seth LaForge <sethml at google dot com> 2013-02-15 20:16:43 UTC ---
Ugh, my attachment was a bit mangled.  Here's the source to stimulate the issue
- gcc_bug.c:

#include <stdio.h>

void PrintDouble(double v) __attribute__((noinline));
void PrintDouble(double v) {
  union { double d; int i[2]; } u = { v };
  printf("%f (0x%08X:%08X)", v, u.i[0], u.i[1]);
}

struct { double val; } __attribute__((packed)) unaligned_double;

void PrintAndStoreUnaligned(double v) __attribute__((noinline));
void PrintAndStoreUnaligned(double v) {
  PrintDouble(v);
  unaligned_double.val = v;
}

int main() {
  double val = 1.234567;
  printf("val is: ");
  PrintDouble(val);
  printf("\nCalling PrintAndStoreUnaligned: ");
  PrintAndStoreUnaligned(val);
  printf("\nunaligned_double.val is: ");
  PrintDouble(unaligned_double.val);
  printf("\n");
  return 0;
}



More information about the Gcc-bugs mailing list