This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/21811] New: Union of odd byte array with integer causes asm constraint to fail
- From: "larry at barello dot net" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 29 May 2005 23:41:19 -0000
- Subject: [Bug c/21811] New: Union of odd byte array with integer causes asm constraint to fail
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
---------- Compiler ---------------
Reading specs from C:/WinAVR/bin/../lib/gcc/avr/3.4.3/specs
Configured with: ../gcc-3.4.3/configure --prefix=m:/WinAVR --build=mingw32
--host=mingw32 --target=avr --enable-languages=c,c++ --with-dwarf2
Thread model: single
gcc version 3.4.3
---------- Error message --------------
avr-gcc -g -Wall -Os -mmcu=atmega16 -DARC -DLED_DDR=DDRB -DLED=PB4
-DLED_PORT=PORTB -DSW_DDR=DDRB -DSW_PORT=PORTB -DSW_PIN=PINB -DSW=PB6
-DF_CPU=16000000 -gdwarf-2 -mshort-calls -c -o foo.o foo.c
foo.c: In function `foo':
foo.c:12: internal compiler error: in emit_move_insn, at expr.c:2809
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://gcc.gnu.org/bugs.html> for instructions.
make: *** [foo.o] Error 1
----------- Source ---------------
#include <inttypes.h>
void foo (void)
{
union
{
uint16_t word;
uint8_t byte[3]; // <<< HERE IS THE BUG
}
bar;
asm volatile (
"\tnop\n"
: :"r" (bar) );
}
------------ commentary --------------
I simplified the test case to the bare essentials.
The error occurs if the union is in SRAM or Registers, but
oddly enough, NOT if it is on the stack (put it there by
taking an address of the union...) If the array "byte" is
made two long, then this doesn't occur. If "word" is a long,
then "byte" needs to be 4 long (or it breaks).
Someone from the avr-gcc list tried this out on the x86 compiler and it failed
there as well (with the union in static ram rather than automatic) so it seems
more generic than just an avr-gcc bug.
--
Summary: Union of odd byte array with integer causes asm
constraint to fail
Product: gcc
Version: 3.4.3
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: larry at barello dot net
CC: gcc-bugs at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21811