Re: Understanding alignment in g++

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

 



Yang Zhang <yanghatespam@xxxxxxxxx> writes:

> I expected a cast-align warning or something.

If you use -Wcast-align you should get a warning for targets where the
cast increases the required alignment.


> How did gcc make the unaligned write work?

You appear to be compiling for the x86.  The x86 supports misaligned
accesses for basic types.  The instructions do what you expect, though
in some cases they will take a few more clock cycles.


> Related: Is there an example of a type that actually has non-1
> alignment on x86(_64)?

There are SSE instructions which required aligned memory addresses
(there are also less efficient SSE instructions which permit misaligned
memory addresses).

Ian

[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