Hello all, I have successfully built SH4-Linux toolchain based on (binutils-2.17, gcc-4.2-20061205, glibc-2.5) for Renesas SH target.
I am facing problem while executing the following C program. ------------------------------------------------------------------ #include <stdio.h> struct structB { int x; int y; }; struct structC { int x; int y; }; main() { struct structC varCs, *varCp=&varCs, **varCpp=&varCp; struct structB *varBp; varCs.x = 10; varCs.y = 20; varBp = *((struct structB **)varCpp); varBp->x = varBp->y; printf("%d",varCs.x); } ------------------------------------------------------------------ The above program compiles successfully with the sh4-linux toolchain. While executing on target platform it is generating wrong result. Observations: 1. When the above program is compiled with '-O0' optimization the value of varCs.x is printed as 20, which is the expected output. Command: sh4-linux-gcc <file name> 2. When the above program is compiled with '-O2' optimization the program is giving following errors: a) "Bus error" when executed on SH7780 Highlander board. b) "Killing process due to unaligned access in user space" when executed on SH7751 R2D board. Command: sh4-linux-gcc -O2 <file name> 3. When the above program is compiled with '-O2' and '-fno-strict-aliasing' option the value of varCs.x is printed as 20. Command: sh4-linux-gcc -O2 -fno-strict-aliasing <file name> Is the above problem related to strict aliasing ? As with 'fno-strict-aliasing' option the above code works fine. Any help on this will be appreciated. Regards, Ashay Jaiswal KPIT Cummins Infosystems Ltd, Pune (INDIA) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Free download of GNU based SH-Linux toolchains for Renesas' SH Series. The following site also offers free technical support to its users. Visit http://www.kpitgnutools.com for details. Latest versions of KPIT GNU SH-Linux tools were released on April 5, 2007. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -- Summary: SH- Aliasing problem for incompatible pointers in c code Product: gcc Version: 4.2.0 Status: UNCONFIRMED Severity: major Priority: P3 Component: c AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: Ashay dot Jaiswal at kpitcummins dot com GCC build triplet: i686-pc-gnu GCC host triplet: sh4-unknown-linux GCC target triplet: sh4-unknown-linux http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31949