public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "Ashay dot Jaiswal at kpitcummins dot com" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c/31949] New: SH- Aliasing problem for incompatible pointers in c code Date: Wed, 16 May 2007 11:55:00 -0000 [thread overview] Message-ID: <bug-31949-14461@http.gcc.gnu.org/bugzilla/> (raw) 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
next reply other threads:[~2007-05-16 11:55 UTC|newest] Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top 2007-05-16 11:55 Ashay dot Jaiswal at kpitcummins dot com [this message] 2007-05-16 14:24 ` [Bug c/31949] " rguenth at gcc dot gnu dot org
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-31949-14461@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).