Re: -Wcast-align and performance

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

 



John Boncek <jboncek@xxxxxxxxxx> writes:

> I have turned on -Wcast-align in a big C++ project for ARM PXA270
> architecture and am receiving many warnings of the form:
>
> warning: cast from `BYTE*' to `short int*' increases required alignment of
> target type
>
> This sounds like there will be a performance penalty to generate the correct
> alignment for this.  Is that correct?

It depends on the actual value of the pointer.  If you take the address
of a short, cast it to char*, and then cast back to short*, you will get
the warning, but there won't be any performance penalty.  In other
words, you will get that warning if you use char* like void*.

If you are taking the address of a char array and then casting that to
short*, then you may indeed have a performance penalty.  And on some
platforms your program won't work at all.

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