Subject: possible bug in gcc
To: port-powerpc <>
From: Erik Anggard <>
List: port-powerpc
Date: 03/16/2003 01:30:19

I'd like to know if it is only my gcc that has been messed up somehow or 
if anyone else running NetBSD on a powerpc arch (I'm running 1.6D 
macppc) can reproduce this bug as shown below. Note: the dummy-function 
used below is of course pretty useless but I'd still like gcc to produce 
at least an blr-instruction at the end. If I remove any of the 
case-blocks or if I use -O0 or -O1 gcc will produce correct code. Very 
strange. (I've also tried the procedure below on an i386 machine and 
there gcc produced correct code with -O2, that's why I posted this 
question on port-powerpc).


$ cc -v
Using builtin specs.
gcc version 2.95.3 20010315 (release) (NetBSD nb3)
$ cat > dummy.c
dummy(int i)
        int n;

        switch (i) {
        case 0:
                n = 0;
        case 1:
                n = 1;
        case 2:
                n = 2;
        case 3:
                n = 3;
        case 4:
                n = 4;
$ cc -O2 -c dummy.c
$ objdump -D dummy.o

dummy.o:     file format elf32-powerpc

Disassembly of section .text:

00000000 <dummy>:
   0:   28 03 00 04     cmplwi  r3,4
Disassembly of section .data: