[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: gperf bug
From: |
Morten Welinder |
Subject: |
Re: gperf bug |
Date: |
25 Jun 2001 16:12:54 -0000 |
|> register int key = hash (str, len);
|> if (key <= MAX_HASH_VALUE && key >= 0)
|> Clearly, "key" should be unsigned and the wasteful test against 0 should
|> be eliminated.
A good compiler will do that anyway.
No way -- the implicit cast cannot be eliminated without an evaluation
of the range of hash, something that is way beyond what you should
expect from compilers. If I had added the -G flag, it would not even
have been computable.
Having put in the right type for "key", I agree that the test is
likely to be eliminated -- with a warning from gcc, *sigh* -- by the
compiler.
Note, that the assignment may even overflow, in which case the currently
generated code will likely do the wrong thing. (But it'll require a
large and strange set of keywords to actually make this happen.
Still, it's a bug that should be fixed.)
|> (And perhaps gperf should use C++ comments in C++ mode.)
What's wrong with using correct comment syntax?
It's not wrong, just out of style.
Morten
- gperf bug, Morten Welinder, 2001/06/25
- Re: gperf bug, Andreas Schwab, 2001/06/25
- Re: gperf bug,
Morten Welinder <=