This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug target/56351] ARM Big-Endian: storing local double to packed variable causes corruption
- From: "sethml at google dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Fri, 15 Feb 2013 20:16:43 +0000
- Subject: [Bug target/56351] ARM Big-Endian: storing local double to packed variable causes corruption
- Auto-submitted: auto-generated
- References: <bug-56351-4@http.gcc.gnu.org/bugzilla/>
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;
}