inline function containing static array omitted from output assembler

Nathan Sidwell nathan@acm.org
Tue Jul 2 06:16:00 GMT 2002


Mark J Roberts wrote:

> typedef unsigned int u32;
> 
> static inline void round(u32 hash[4], const u32 block[4])
> {
>         static const u32 table[256] = {};
>         hash[0] = (hash[0] ^ hash[3]) + block[0];
>         hash[0] = hash[0] >> 8 ^ table[hash[0] & 0xff];
>         hash[1] = (hash[1] ^ hash[0]) + block[1];
>         hash[1] = hash[1] >> 8 ^ table[hash[1] & 0xff];
>         hash[2] = (hash[2] ^ hash[1]) + block[2];
>         hash[2] = hash[2] >> 8 ^ table[hash[2] & 0xff];
>         hash[3] = (hash[3] ^ hash[2]) + block[3];
>         hash[3] = hash[3] >> 8 ^ table[hash[3] & 0xff];
> }
> 
> void bug(void)
> {
>         u32 hash[4], block[4];
>         for (;;)
>                 round(hash, block);
> }
this code is equivalent to
	while (true);
which is what it was optimized to. There are no exits from the loop,
all code paths within the loop are visible, no globall objects
are altered.

When you put printfs in, you changed the meaning of the program.

Doesn't look like a bug to me.

nathan
-- 
Dr Nathan Sidwell :: Computer Science Department :: Bristol University
           The voices in my head told me to say this
nathan@acm.org  http://www.cs.bris.ac.uk/~nathan/  nathan@cs.bris.ac.uk



More information about the Gcc-bugs mailing list