This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Information regarding issue with While Loop with O3 optimization


Raghukrishna Hegde wrote:
Hello all,
    I am encountering a strange problem. I have a code
Snippet that contains a while loop.

The snippet is as follows:

While( (expr1) && (expr2) );

    Initially the value of both expr1 and expr2 are
Set to 1.

Next, only the value of expr1 is set to 0 within a SIGINT handler.

you need to make expr1 volatile for this to work, the optimizer does not have to take care of the possibility of a handler changing a variable otherwise.



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]