strict alias analysis question
Mike Stump
mrs@apple.com
Tue Oct 14 20:58:00 GMT 2003
On Tuesday, October 14, 2003, at 09:52 AM, Manfred Spraul wrote:
> the latest gcc versions generate warnings about potentially dangerous
> pointer casts if strict alias analysis is enabled.
> Right now two groups of warnings are generated: several from the
> inlined MemSet macros:
>
> #define MemSetLoop(start, val, len) \
> do \
> { \
> int32 * _start = (int32 *) (start); \
> int32 * _stop = (int32 *) ((char *) \
> _start + (Size) (len)); \
> \
> while (_start < _stop) \
> *_start++ = 0; \
> } while (0)
> Does MemSet break the rules for strict alias analysis?
No, it'll work fine for all int32 arrays. Will it work for anything
else, no, sorry. Well, it might work for a few other things, like char
arrays that are a multiple of around 4 bytes... I'd recommend reading
up, the standard is fairly clear and easy to read in this area.
Hint, use memcpy/memmove instead, it works.
More information about the Gcc
mailing list