Bug 21811 - Union of odd byte array with integer causes asm constraint to fail
Summary: Union of odd byte array with integer causes asm constraint to fail
Status: RESOLVED DUPLICATE of bug 8788
Alias: None
Product: gcc
Classification: Unclassified
Component: c (show other bugs)
Version: 3.4.3
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-05-29 23:41 UTC by larry barello
Modified: 2005-07-23 22:49 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments
test case (161 bytes, text/plain)
2005-05-29 23:42 UTC, larry barello
Details

Note You need to log in before you can comment on or make changes to this bug.
Description larry barello 2005-05-29 23:41:17 UTC
---------- 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.
Comment 1 larry barello 2005-05-29 23:42:10 UTC
Created attachment 8987 [details]
test case
Comment 2 Andrew Pinski 2005-05-29 23:48:12 UTC

*** This bug has been marked as a duplicate of 8788 ***