public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* strict alias analysis question
@ 2003-10-14 17:02 Manfred Spraul
  2003-10-14 20:58 ` Mike Stump
  0 siblings, 1 reply; 2+ messages in thread
From: Manfred Spraul @ 2003-10-14 17:02 UTC (permalink / raw)
  To: gcc

Hi,

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)

And a few from structures with common headers:

struct hdr {
    ...;
}
struct b {
    struct hdr info;
    ...
};

void handler(struct hdr* parm)
{
    struct b* ptr = (struct b*)parm;
}

Does MemSet break the rules for strict alias analysis? And what about 
manual base classes? The actual use it a bit longer (the cast to (Node 
*) in src/backend/commands/tablecmds.c generates the warning).

--
    Manfred

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: strict alias analysis question
  2003-10-14 17:02 strict alias analysis question Manfred Spraul
@ 2003-10-14 20:58 ` Mike Stump
  0 siblings, 0 replies; 2+ messages in thread
From: Mike Stump @ 2003-10-14 20:58 UTC (permalink / raw)
  To: Manfred Spraul; +Cc: gcc

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.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2003-10-14 18:21 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-10-14 17:02 strict alias analysis question Manfred Spraul
2003-10-14 20:58 ` Mike Stump

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).