public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/40946]  New: [4.3/4.4/4.5 Regression] Spurious array subscript is above bounds warning
@ 2009-08-03  8:27 jakub at gcc dot gnu dot org
  2009-08-08 22:58 ` [Bug middle-end/40946] " steven at gcc dot gnu dot org
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: jakub at gcc dot gnu dot org @ 2009-08-03  8:27 UTC (permalink / raw)
  To: gcc-bugs

/* { dg-do compile } */
/* { dg-options "-O2 -Wall" } */

struct A
{
  unsigned char a1[8];
  unsigned short a2, a3, a4, a5, a6, a7;
};

int bar (void *, const char *, int);
char *foo (void *, int);

char *
baz (const char *x, const char *y)
{
  int a = sizeof (struct A) + 2 * (__builtin_strlen (y)
   + __builtin_strlen (x) + 24) + 16;
  struct A *b = __builtin_malloc (a);
  char *c;
  int d;

  b->a4 = sizeof (struct A);
  c = ((char *) b) + b->a4;
  d = ((char *) b) + a - c;
  b->a2 = b->a3 = (unsigned short) bar (c, y, d);/* { dg-bogus "array subscript
is above array bounds" } */
  c += b->a2;
  d = ((char *) b) + a - c;
  b->a7 = b->a4 + b->a2;
  b->a5 = b->a6 = (unsigned short) bar (c, x, d);
  c = foo (b, a);
  return c;
}

gives a spurious warning, because the cast of the struct to char pointer is
folded into array ref on the first field.


-- 
           Summary: [4.3/4.4/4.5 Regression] Spurious array subscript is
                    above bounds warning
           Product: gcc
           Version: 4.4.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: middle-end
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: jakub at gcc dot gnu dot org
GCC target triplet: powerpc-linux


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40946


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

end of thread, other threads:[~2010-05-22 18:33 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-08-03  8:27 [Bug middle-end/40946] New: [4.3/4.4/4.5 Regression] Spurious array subscript is above bounds warning jakub at gcc dot gnu dot org
2009-08-08 22:58 ` [Bug middle-end/40946] " steven at gcc dot gnu dot org
2009-08-16 21:41 ` rguenth at gcc dot gnu dot org
2009-08-16 21:42 ` rguenth at gcc dot gnu dot org
2009-11-09 15:48 ` jakub at gcc dot gnu dot org
2009-11-09 15:51 ` rguenther at suse dot de
2009-11-09 19:39 ` jakub at gcc dot gnu dot org
2009-11-09 19:41 ` jakub at gcc dot gnu dot org
2009-11-09 19:44 ` [Bug middle-end/40946] [4.3 " jakub at gcc dot gnu dot org
2010-05-22 18:33 ` rguenth at gcc dot gnu dot org

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