This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug rtl-optimization/28611] New: wrong code generated when cast to union is used
- From: "awit at po dot opole dot pl" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 5 Aug 2006 17:56:30 -0000
- Subject: [Bug rtl-optimization/28611] New: wrong code generated when cast to union is used
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
source code:
typedef union {
int word;
char byte[2];
} Union;
int proc(int l)
{
if (l < 0 )
((Union)l).byte[0] = 0;
return l;
}
command line for avr:
avr-gcc -mmcu=atmega8 -S -Os test.c
Procedure proc is compiled to single ret instruction.
command line for i586:
gcc -c -Os test.c
Procedure proc is compiled to frame initialization code and ret instruction.
For casting to union used in conditionaly expression :
if (((Union)l).byte[1] & 0x80)
l = 0;
corect code is genereted.
System SUSE 10.1
avr-gcc onfigured with: ../configure --prefix=/opt/cross
--with-local-prefix=/usr/local --infodir=/opt/cross/share/info
--mandir=/opt/cross/share/man --libdir=/opt/cross/lib
--libexecdir=/opt/cross/lib --enable-languages=c,c++ --enable-checking=release
--with-gxx-include-dir=/usr/include/c++/4.1.0 --enable-ssp --disable-libssp
--disable-libgcj --with-slibdir=/lib --with-system-zlib --enable-shared
--enable-__cxa_atexit --enable-libstdcxx-allocator=new --target=avr
--disable-nls --disable-shared --host=i586-suse-linux
i586 gcc configured with: ../configure --enable-threads=posix --prefix=/usr
--with-local-prefix=/usr/local --infodir=/usr/share/info
--mandir=/usr/share/man --libdir=/usr/lib --libexecdir=/usr/lib
--enable-languages=c,c++,objc,fortran,java,ada --enable-checking=release
--with-gxx-include-dir=/usr/include/c++/4.1.0 --enable-ssp --disable-libssp
--enable-java-awt=gtk --enable-gtk-cairo --disable-libjava-multilib
--with-slibdir=/lib --with-system-zlib --enable-shared --enable-__cxa_atexit
--enable-libstdcxx-allocator=new --without-system-libunwind --with-cpu=generic
--host=i586-suse-linux
--
Summary: wrong code generated when cast to union is used
Product: gcc
Version: 4.1.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: rtl-optimization
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: awit at po dot opole dot pl
GCC host triplet: i586-suse-linux
GCC target triplet: avr, i586-suse-linux
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28611