[llvm-commits] [llvm-gcc] Potential bug in iasm_extra_clobbers ??
Reid Spencer
rspencer at reidspencer.com
Mon Jan 15 19:32:28 PST 2007
Applites,
While I've been perusing c-common.c, I have found a warning that you
might not be seeing because of compiler differences:
../../src-2/gcc/c-common.c: In function ‘iasm_extra_clobbers’:
../../src-2/gcc/c-common.c:7017: warning: comparison of unsigned expression < 0 is always false
This comes from this function:
> static void
> iasm_extra_clobbers (const char *opcode, tree *clobbersp)
> {
> struct iasm_op_clobber db[] = { IASM_EXTRA_CLOBBERS };
Note number of elements of db is 1.
> struct iasm_op_clobber key;
> struct iasm_op_clobber *r;
> const char **clobbers;
> int num;
>
> /* APPLE LOCAL LLVM */
> #if defined(TARGET_IASM_EXTRA_CLOBBERS) && defined(ENABLE_CHECKING)
> /* Ensure that the table is sorted. */
> static int once;
> if (once == 0)
> {
> size_t i;
> once = 1;
> for (i=0; i < sizeof (db) / sizeof(db[0]) - 1; ++i)
Are you sure you want to subtract one from the size computation? Perhaps
at one time this was null terminated? In any event (sizeof(db) /
sizeof(db[0])) == 1, which if you subtract 1 from it is causing the
unsigned range warning on the comparison with i.
Not sure if this matters, but thought I'd point it out.
> gcc_assert (iasm_op_clobber_comp (&db[i+1], &db[i]) >= 0);
> }
> #endif
>
More information about the llvm-commits
mailing list