Comment 8 for bug 1353142

Revision history for this message
Alan Modra (amodra) wrote :

No, const doesn't make any difference.

On looking again at the source, I've come to the conclusion that this isn't a vectorizer bug after all. It is simply a coding error.

A compiler is allowed to assume that a pointer to a type is aligned suitably for the type. So in
 *(apr_uint32_t *)target = *(apr_uint32_t *)source;
gcc is allowed to assume that source and target are 4-byte aligned, but they are not..
Modifying the code to use an unaligned 4-byte type here cures the problem.

Quoting from ISO/IEC 9899:1999
6.3.2.3 Pointers
...
7 A pointer to an object or incomplete type may be converted to a pointer to a different
 object or incomplete type. If the resulting pointer is not correctly aligned for the
pointed-to type, the behavior is undefined.