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 target/56351] ARM Big-Endian: storing local double to packed variable causes corruption


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;
}


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