http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56341

--- Comment #11 from Bernd Edlinger <bernd.edlinger at hotmail dot de> ---
Created attachment 30248
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=30248&action=edit
another example of the alignment faults

Hello Sandra,

good that you continue to work on that bug again.

I agree that there may be two completely different aspects of this bug.
Attached you'll find a new test program that came in my mind when I
looked at PR 41809, the structure s is aligned 2 and packed.
If you make it an array of size 10, each second call of f is given
an odd pointer. But the compiler should know that because of the
aligned(2) attribute.

What is the difference to PR 41809 is this:
1. PR 41809 is not a correct C-program at all, and has never been.
   While this attached new test program is correct C program.
   previous GCC versions did compile that correctly, current GCC does not even
   emit a warning.

2. PR 41809 is not about volatile at all.
   However if you remove the "volatile" in the test program(s),
   the code is correct and does no longer use unaligned addresses.

On the other hand, "volatile" might mean that the compiler
should try not to optimize the read instructions, for instance in loops.
But of course not to an extent that the generated code is no longer valid.

Reply via email to