--- Comment #3 from pinskia at gcc dot gnu dot org 2008-10-14 21:59 ---
There are two aliasing violations here.
The first is what Richard mentioned and the second is also in foo, there is a
load from p via long* and also a store via void*. That is where the issue
comes down to here and
--- Comment #2 from rguenth at gcc dot gnu dot org 2008-10-14 13:20 ---
It is indeed an aliasing violation, you store a long and read a long*.
Fix it like
int main()
{
int i;
long a;
long **b = malloc(8 * sizeof(long));
for (i = 0; i < 8; i++)
--- Comment #1 from anton at samba dot org 2008-10-14 11:59 ---
Alan Modra points out the cast is not required and removing it does fix the
issue.
BTW -Wstrict-aliasing (or -Wstrict-aliasing=2) doesn't warn about the code.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37824