On Sat,  5 Oct 2013 at 11:36:00 +0100, Iain Patterson wrote:
> Quoth Carlos R. Mafra,
> 
> >switchpanel.c: In function 'wSwitchPanelSelectFirst':
> >switchpanel.c:673:18: warning: variable 'tmpwin' set but not used
> >[-Wunused-but-set-variable]
> >[...]
> >which looks bogus. Is there any compiler food for this case?
> 
>   It is indeed bogus.  The variable is used in WM_ITERATE_ARRAY().
> However the compiler is trying very hard to be smarter than me,
> which isn't difficult at the best of times.
> 
>   I tried declaring tmpwin as volatile but that didn't fool it.  I
> tried initialising tmpwin explicitly but the compiler still
> complained that I wasn't doing anything useful with tmpwin.  The
> only way I could silence the warning was by inserting some pointless
> redundant code like "if (tmpwin == wwin) tmpwin = NULL;" to fool the
> compiler.  That's ugly and pretty stupid.
> 
>   And annoying because gcc is wrong; the variable is not unused at all.
> 
>   Another answer might be to copy wwin to tmpwin then reuse wwin in
> WM_ITERATE_ARRAY() and return tmpwin at the end of the function.
> Again, inelegant as well as inconsistent with other uses of tmpwin
> inside iterations elsewhere in the code.
> 
>   I see three choices.
> 
>   1. Wait for someone who knows more about compiler innards to tell
> us the "right" thing to do.
> 
>   2. Accept that the code compiles with warnings on the basis that
> we know why the warning is issued and understand that it is not a
> valid complaint.
> 
>   3. Burn some CPU cycles with pointless code that tricks gcc into
> being wrong about being wrong, therefore right.
> 
>   As an aside, I compile with clang and it didn't complain, so
> thanks for bringing the gcc warning to my attention.

Thanks Iain for the effort and reporting back!

Looks like 1. is the best option for now.

I hope there are more people using the --enable-silent-rules option for
'configure' and seeing these things.


-- 
To unsubscribe, send mail to [email protected].

Reply via email to