Re: Compiler message -Wunused confusion

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Feb 14, 2024 at 1:42 PM Segher Boessenkool <
segher@xxxxxxxxxxxxxxxxxxx> wrote:

> On Wed, Feb 14, 2024 at 03:11:58AM -0800, A. Mc. via Gcc-help wrote:
> > volatile bool foo;
> >
> > while (true) {
> > if (foo == true){
> >        //do something
> >        foo = false;}
> > else{
> >        //do something else
> >        foo = true;}
> > }
> >
> > Which never switches. What could be the cause of this?
>
> Your code assigns to foo, but never uses foo again.  This is likely a
> programming mistake, which is what the warning is for.
>

What do you mean by "never uses foo again"? In each iteration foo is
compared to true and in each iteration it is flipped, so it should be true,
false, true, false and so on.
-- 
Jędrzej Dudkiewicz

I really hate this damn machine, I wish that they would sell it.
It never does just what I want, but only what I tell it.




[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux