https://gcc.gnu.org/bugzilla/show_bug.cgi?id=44478
Marek Polacek changed:
What|Removed |Added
Status|UNCONFIRMED |RESOLVED
CC|
--- Comment #1 from paolo dot carlini at oracle dot com 2010-06-09 09:49
---
I'm sure you are right, but I don't understand your explanation: even when
SYMBOL
is undefined, why no code actually uses (roughly speaking, reads) var? That's
the point of the warning and your example doesn't
--- Comment #2 from jakub at gcc dot gnu dot org 2010-06-09 09:53 ---
The warning is useful and can find (and already found) several real bugs e.g.
in gcc itself. Icc has similar warning.
If kernel has lots of useless code like that and doesn't wish to use this
warning, it can add
--- Comment #3 from andi-gcc at firstfloor dot org 2010-06-09 10:13 ---
Sorry my example was not very good.
Anyways this typically happens with #ifdefs, so the some ifdef path
is actually using the variable, it's just not enabled in the current build.
In theory the ifdefs could be put
--- Comment #4 from jakub at gcc dot gnu dot org 2010-06-09 10:52 ---
We don't warn on
void foo (void)
{
int dummy;
asm ( : =r (dummy));
}
- the use in the asm is considered as a use, not just set.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44478
--- Comment #5 from andi-gcc at firstfloor dot org 2010-06-09 11:08 ---
Hmm yes there was another temporary and a inline inbetween
unsigned inlinefunc(void)
{
unsigned var;
asm( ... : =r (var));
return var;
}
#define macro(x,y)
{
unsigned var = inlinefunc();
x = var;
y =
--- Comment #6 from jakub at gcc dot gnu dot org 2010-06-09 11:36 ---
Then it has nothing to do with the asm.
If the macro is widely used and very often sets a var that isn't used, all
you can do is add (void) cast to shut the warning up.
(void) (y = var 16);
in this case.
--