public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* warning: array subscript is below array bounds
@ 2009-06-10  6:33 George Kirpichev
  0 siblings, 0 replies; only message in thread
From: George Kirpichev @ 2009-06-10  6:33 UTC (permalink / raw)
  To: pinskia; +Cc: gcc-bugs

Hi,

I would like to ask a question about array bounds checking feature in gcc.

My question is the following:

There is a code like:

    /* put message in buffer */
    (void) memcpy(sockFact_p->sockBuffer_p + sockFact_p->usedSize,
                  (char*)mqp_sp->msg.data - MSG_HEADER_LENGTH,
                  mqp_sp->msg.size + MSG_HEADER_LENGTH);

Where
mqp_sp->msg is
typedef struct MSGBUF_TAG
{
    W16 msgType_l;
    W16 receiver;
    W8  primitive;
    W8 remoteInstance;
    W16 size;
    int free;
    W16 poolId;
    W16 usedCounter;
    char   sendHead[MSG_HEADER_LENGTH];
    W8  data[MSG_MAX_DATALEN]; /* 4- or 8-octet alignment */
} MSGBUF_T;

Should the code snippet produce the warning:
warning: array subscript is below array bounds

And why if should?

>From my point of view type cast is more prioritized operation, thus
it should be ok. But seems, that gcc thinks in other way.

I've checked it with GCC 4.4.0 and warning has been emited.

What is you oppinion regarding that.

Should I create new BUG on GCC or something is wrong in our code?

BR/ Yury





^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2009-06-10  6:33 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-06-10  6:33 warning: array subscript is below array bounds George Kirpichev

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).