On Apr 19, 2006, at 1:56 AM, Olivier Tristan wrote: Ben Weiss wrote: All right, so I tried it in assembly, and ran into another bug (I think):
Given the function:
static int duplicatelabelbug(register vector unsigned short a, register vector unsigned short b) { register vector unsigned short vmask; asm { vcmpgtuh. vmask, a, b; beq cr6, mylabel; }; asm { vcmpgtuh. vmask, b, a; beq cr6, mylabel; }; // <-- duplicate label?? return 0; mylabel: return 1; // <-- label only defined once, here! }
XCode 2.2.1 / gcc 4.0 generates: "error: duplicate label 'LASM$mylabel' " even though the label "mylabel" is only defined once. (CodeWarrior handles this code just fine.) Is this a gcc bug?
Hi,
It seems that this function is inlined so it duplicates the label. You should use gcc local label However I never used those.
Try compiling this function in XCode:
static int test(int a, int b, int c) { if (a > b) goto mylabel;
return 1;
__label__ mylabel: return 0; }
XCode goes into an infinite loop when I try to compile this Granted, it's not the correct syntactic use of the keyword __label__, but the compiler should still handle it gracefully... And even when the __label keyword__ is properly used, it still fails to work around the original bug, which it seems is related to the inline assember. For example, the following function compiles just fine:
static int thisworks(int a, int b, int c) { if (a > b) goto mylabel; if (b > c) goto mylabel;
return 1;
mylabel: return 0; }
but this one generates an error:
static int thisdoesntwork(int a, int b, int c) { asm { cmplw a, b; bgt mylabel; } asm { cmplw b, c; bgt mylabel; }
return 1;
mylabel: return 0; }
Does it do the same thing there? Any ideas?
Ben |