Re: Possible bug in gcc 4.4.7

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

 



On 17 September 2014 17:16, Andy Falanga (afalanga) wrote:
> Flag operator &=(Flag& f1, Flag f2) {
>         return static_cast<Flag>(reinterpret_cast<unsigned int&>(f1) &= static_cast<unsigned int>(f2));
> }

That reinterpret_cast looks dodgy to me, accessing the object through
a different type is undefined behaviour. What's wrong with doing it
safely?

Flag operator &=(Flag& f1, Flag f2) {
  unsigned int i = f1;
  i &= static_cast<unsigned int>(f2);
  return f1 = static_cast<Flag>(i);
}




[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