And if you can't detect it, the standard doesn't require it.
There is at least one real consequence of the requirement. Converting
from one pointer type to another invokes UB if the resulting pointer
is not correctly aligned. So this:
long double *ptr = malloc(1);
does *not* invoke UB even if you can't store a long double in the
allocated memory.
But if the implementation doesn't impose alignment requirements on
converted pointers, but does impose alignment requirements on objects,
then an implementation can get away with having malloc(1) return a
misaligned pointer without any portable program being able to detect
it.
What I mean by the above is, for example, if a long double object must
always be aligned on an 8-byte boundary (attempting to read or write a
misaligned long double invokes UB), but all pointers are just byte
pointers, and constructing a 'long double*' that points to an odd
address doesn't do anything nasty.
[...]
--
Keith Thompson (The_Other_Keith) (e-mail address removed) <
http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <
http://users.sdsc.edu/~kst>
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"