http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55146



Oleg Endo <olegendo at gcc dot gnu.org> changed:



           What    |Removed                     |Added

----------------------------------------------------------------------------

                 CC|                            |olegendo at gcc dot gnu.org



--- Comment #1 from Oleg Endo <olegendo at gcc dot gnu.org> 2012-12-10 09:15:15 
UTC ---

(In reply to comment #0)

> Created attachment 28580 [details]

> testcase C file

> 

> Switch statement with enough cases inside is translated to jumptable. If the

> offsets are small enough, byte entries are used. If there is odd number of

> cases this implies padding byte (since all SH instructions are 2 byte wide). 
> In

> the corner case this padding byte can cause the offset to switch from positive

> to negative since move.b instruction used to fetch jumptable entry sign 
> extends

> the byte. This bug is very old and dates back at least to 4.0.3 days. See

> attachment.

> When compiled with sh-elf-gcc -Os -c test-jens.c -o sh-test.o it produces 
> wrong

> jumping code. http://pastebin.com/ZgJK3bgS has slightly commented disassembly

> to point out what I mean.

> 

> The workaround is to decrease MIN_OFFSET by one for byte case in

> gcc/config/sh/sh.h . This is not a proper fix though.



Thanks for reporting this.  Could you please attach the file that you had on

pastebin?  The link seems dead.

Reply via email to