Package: gcc-2.95
Version: 2.95.4-5

[EMAIL PROTECTED]:/tmp$ cat b.c 
int x;
main()
{
        unsigned long n;
        switch (x) {
                case 6: n = 32; break;
                case 5: case 7: case 8: case 11: n = 128; break; 
        }

        x = 0;
        printf("%d\n", x);
}
[EMAIL PROTECTED]:/tmp$ gcc b.c && ./a.out 
0
[EMAIL PROTECTED]:/tmp$ gcc -O2 b.c && ./a.out 
Segmentation fault
[EMAIL PROTECTED]:/tmp$ uname -a
Linux wynton 2.2.18pre21 #1 Wed Nov 22 05:08:09 CST 2000 alpha unknown

It's a cc1 problem - code it generates looks so:
main:
        .frame $30,16,$26,0
        .mask 0x4000000,-16
        ldgp $29,0($27)
$main..ng:
        lda $2,x
        lda $30,-16($30)
        stq $26,0($30)
        .prologue 1
        fnop
        ldl $1,0($2)
        mov $2,$3
        subl $1,5,$1
        zapnot $1,15,$1
        cmpule $1,6,$1
        .end main

IOW, instead of removing switch() it had left the very beginning of switch()
code in there and killed everything after it.  Including ret.


On x86 resulting code works, but it looks rather funny - even with -O6 we
end up with
        movl    x,%eax
        subl    $5,%eax
        /* values of %eax and flags are never used below */

So it looks like dead code removal is very fishy.



-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]


Reply via email to