Re: ++-bug on enums with -O2 in version 4.4

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

 



My suspicion is that this is illegal to do with enums.

On Thu, Aug 5, 2010 at 9:54 AM,  <gcc@xxxxxxxx> wrote:
> Hello,
>
> I discovered what seems to be a bug in G++ 4.4 (that was not there in
> prior versions and seems already fixed in 4.5) and am wondering if
> there's some information available what exactly the problematic cases
> are, so that I know which places in my code to verify/adapt.
>
> It was a "caching" problem when -O2 was enabled and an enum variable was
> checked and increased in a loop and then finally checked again, all in
> some very near code-lines. The final check did get an old "cached" value
> of the variable, while the code below that worked with the actual value.
>
> When I changed the declaration of the variable from my enum type to
> "volatile" or to "int", then it worked. The question is if the following
> is probably illegal C++-code, although I don't think so?
>
>        myEnumType myVariable;
>
>        myVariable = myEnumType (myVariable + 2);
>
> (I extracted that piece of code into a small test-program and that
> worked, strangely.)
>
> If someone has answers to those two questions, that'd be very nice.
> Thanks so far for reading.
>
> Cheers!
> Martin
>



[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