Re: Can I thrust in GCC doing the right thing when casting to a wider type in C?

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

 



On Sat, Aug 03, 2019 at 09:30:59AM +0200, Aaron wrote:
> Can I thrust in GCC doing the right thing when casting to a wider type 
> in C, now and in the future?

Yes.  There can be bugs, of course.

> Unfortunately, it is not valid C due to the effective type rules. (6.5 
> Expression 7).

>                 // this is safe due to the check: if(... 
> above

No it's not.  It likely isn't valid code (unless d and s happen to
always point to things with effective type int here).

>                 *(unsigned*)d=*(const unsigned*)s; // <===== 
> line in question

If you don't like 6.5/7, and you don't mind slower code, you can use
-fno-strict-aliasing .


Segher



[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