aliasing warnings [patch]
Mark Mitchell
mark@codesourcery.com
Thu Sep 30 23:58:00 GMT 1999
|> I think your idea is probably a good one, but your statement is not
|> 100% correct. Consider:
|>
|> int i;
|> int *ip = &i;
|> double *dp = (double *) ip;
|> int *ip2 = (int*) dp;
|>
|> *ip2 = 3;
If i is not correctly aligned for double then the behaviour is undefined
(C9x 6.3.2.3 [#7]). Thus this may not be valid, independent of aliasing
issues.
Of course. (Actually, aren't pointer casts undefined only if the
number of bits used to represent the pointers are different? I
thought the behavior was just implementation-defined, otherwise. But,
I believe you.)
But, we've already agreed to forgo discussing alignment issues when
discussing these aliasing questions. Let's not get sidetracked from
the core issue.
--
Mark Mitchell mark@codesourcery.com
CodeSourcery, LLC http://www.codesourcery.com
More information about the Gcc-patches
mailing list