public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/37861]  New: Bogus array bounds warning
@ 2008-10-17  8:27 rguenth at gcc dot gnu dot org
  2008-10-30 17:46 ` [Bug middle-end/37861] " jamborm at gcc dot gnu dot org
                   ` (16 more replies)
  0 siblings, 17 replies; 18+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2008-10-17  8:27 UTC (permalink / raw)
  To: gcc-bugs

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1609 bytes --]

extern int printf (__const char *__restrict __format, ...);

  static int f2(char formatstr[10][100]) {
    int anz;
    for( anz = 0; anz < 10; ++anz ) {
      printf( "%d %s\n", anz, formatstr[anz] );
    } 
    return anz;
  }


  static   char formatstr[10][100];
  int main( void ) {
    int anz;
    anz = f2(formatstr);
    printf( "   %d\n",anz);
    return 0;
  }


with -O3 -Wall this reports

t.c: In function ‘main’:
t.c:6: warning: array subscript is above array bounds
t.c:6: warning: array subscript is above array bounds
t.c:6: warning: array subscript is above array bounds
t.c:6: warning: array subscript is above array bounds
t.c:6: warning: array subscript is above array bounds
t.c:6: warning: array subscript is above array bounds
t.c:6: warning: array subscript is above array bounds
t.c:6: warning: array subscript is above array bounds

because we end up with

<bb 3>:
  # anz_23 = PHI <anz_6(4), anz_22(6)>
  D.1572_5 = (long unsigned int) anz_23;
  D.1573_7 = D.1572_5 * 100;
  D.1574_8 = &formatstr[0][D.1573_7];
  printf (&"%d %s\n"[0], anz_23, D.1574_8);
  anz_9 = anz_23 + 1;

<bb 4>:
  # anz_6 = PHI <anz_9(3)>
  if (anz_6 <= 9)
    goto <bb 3>;
  else
    goto <bb 5>;


-- 
           Summary: Bogus array bounds warning
           Product: gcc
           Version: 4.3.2
            Status: UNCONFIRMED
          Keywords: diagnostic
          Severity: normal
          Priority: P3
         Component: middle-end
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: rguenth at gcc dot gnu dot org


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


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

end of thread, other threads:[~2009-02-28 22:46 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-10-17  8:27 [Bug middle-end/37861] New: Bogus array bounds warning rguenth at gcc dot gnu dot org
2008-10-30 17:46 ` [Bug middle-end/37861] " jamborm at gcc dot gnu dot org
2008-10-30 18:45 ` manu at gcc dot gnu dot org
2008-10-31 17:54 ` jamborm at gcc dot gnu dot org
2008-10-31 18:02 ` jamborm at gcc dot gnu dot org
2008-11-04 15:52 ` jamborm at gcc dot gnu dot org
2008-11-05  9:56 ` [Bug middle-end/37861] [4.3/4.4 Regression] " rguenth at gcc dot gnu dot org
2008-11-05 16:09 ` jamborm at gcc dot gnu dot org
2008-11-05 20:51 ` [Bug middle-end/37861] [4.3 " jakub at gcc dot gnu dot org
2008-11-10 10:07 ` jamborm at gcc dot gnu dot org
2008-11-10 18:41 ` jamborm at gcc dot gnu dot org
2008-11-15  0:01 ` pinskia at gcc dot gnu dot org
2008-11-30 23:02 ` rguenth at gcc dot gnu dot org
2008-12-02 14:34 ` jamborm at gcc dot gnu dot org
2009-01-24 10:26 ` rguenth at gcc dot gnu dot org
2009-02-28  0:31 ` jamborm at gcc dot gnu dot org
2009-02-28 18:33 ` jamborm at gcc dot gnu dot org
2009-02-28 22:46 ` jamborm 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).