public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/61277] New: Incorrect -Warray-bounds warning with 4.9.0
@ 2014-05-22  0:06 akruppa at gmail dot com
  2021-08-08  3:20 ` [Bug tree-optimization/61277] " pinskia at gcc dot gnu.org
  0 siblings, 1 reply; 2+ messages in thread
From: akruppa at gmail dot com @ 2014-05-22  0:06 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61277

            Bug ID: 61277
           Summary: Incorrect -Warray-bounds warning with 4.9.0
           Product: gcc
           Version: 4.9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: akruppa at gmail dot com

The following code, when compiled with the gcc 4.9.0 release or with SVN branch
gcc-4_9-branch r210719, via

gcc -O2 -Wall -c bug.c

produces the warning

bug.c: In function ‘foo’:
bug.c:13:8: warning: array subscript is below array bounds [-Warray-bounds]
   if (s[n-1] != 2)
        ^

If foo() returns 2, the array accesses are not out of bounds.

Gcc 4.8.1 does not produce the warning. 
The gcc 4.9.0 and SVN builds were configured with

configure --prefix=install/dir/ --enable-languages=c,c++


int foo();
int s[2];
int bar()
{
  int n = foo();
  int i;

  for(i = 0 ; i < n ; i++)
    if ((i == 0) != (s[i] == 0))
      return 0;
  if (s[n-1] != 2)
      return 0;   
  for(i = 0 ; i < n ; i++)
      if (s[0])
        return 0;
  return 1;
}
>From gcc-bugs-return-452210-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Thu May 22 00:18:47 2014
Return-Path: <gcc-bugs-return-452210-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 26087 invoked by alias); 22 May 2014 00:18:46 -0000
Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm
Precedence: bulk
List-Id: <gcc-bugs.gcc.gnu.org>
List-Archive: <http://gcc.gnu.org/ml/gcc-bugs/>
List-Post: <mailto:gcc-bugs@gcc.gnu.org>
List-Help: <mailto:gcc-bugs-help@gcc.gnu.org>
Sender: gcc-bugs-owner@gcc.gnu.org
Delivered-To: mailing list gcc-bugs@gcc.gnu.org
Received: (qmail 25756 invoked by uid 48); 22 May 2014 00:18:37 -0000
From: "su at cs dot ucdavis.edu" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug lto/61278] New: ICE with LTO (lto-wrapper failed) on x86_64-linux-gnu in 64-bit mode
Date: Thu, 22 May 2014 00:18:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: new
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: lto
X-Bugzilla-Version: 4.10.0
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: su at cs dot ucdavis.edu
X-Bugzilla-Status: UNCONFIRMED
X-Bugzilla-Priority: P3
X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org
X-Bugzilla-Target-Milestone: ---
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter
Message-ID: <bug-61278-4@http.gcc.gnu.org/bugzilla/>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/
Auto-Submitted: auto-generated
MIME-Version: 1.0
X-SW-Source: 2014-05/txt/msg01902.txt.bz2
Content-length: 2964

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61278

            Bug ID: 61278
           Summary: ICE with LTO (lto-wrapper failed) on x86_64-linux-gnu
                    in 64-bit mode
           Product: gcc
           Version: 4.10.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: lto
          Assignee: unassigned at gcc dot gnu.org
          Reporter: su at cs dot ucdavis.edu

The current gcc trunk produces an ICE on the following code when using LTO on
x86_64-linux-gnu in 64-bit mode (but not 32-bit). 

This is a regression from 4.9.x. 

$ gcc-trunk -v
Using built-in specs.
COLLECT_GCC=gcc-trunk
COLLECT_LTO_WRAPPER=/usr/local/gcc-trunk/libexec/gcc/x86_64-unknown-linux-gnu/4.10.0/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: ../gcc-trunk/configure --prefix=/usr/local/gcc-trunk
--enable-languages=c,c++ --disable-werror --enable-multilib
Thread model: posix
gcc version 4.10.0 20140521 (experimental) [trunk revision 210675] (GCC) 
$ 
$ gcc-4.9.0 -flto -O0 -c foo.c
$ gcc-4.9.0 -flto -O1 -c main.c
$ gcc-4.9.0 -flto -O1 foo.o main.o
$ a.out
$ 
$ gcc-trunk -O0 -c foo.c
$ gcc-trunk -O1 -c main.c
$ gcc-trunk -O1 foo.o main.o
$ a.out
$ 
$ gcc-trunk -flto -O0 -c foo.c
$ gcc-trunk -flto -O1 -c main.c
$ gcc-trunk -flto -O1 foo.o main.o
foo.c: In function ‘foo’:
foo.c:26:1: internal compiler error: Segmentation fault
 }
 ^
0x8c28df crash_signal
    ../../gcc-trunk/gcc/toplev.c:337
0x513b40 bitmap_clear
    ../../gcc-trunk/gcc/bitmap.c:311
0x513b40 bitmap_copy(bitmap_head*, bitmap_head const*)
    ../../gcc-trunk/gcc/bitmap.c:534
0x89a7f7 move_insn_for_shrink_wrap
    ../../gcc-trunk/gcc/shrink-wrap.c:209
0x89a7f7 prepare_shrink_wrap(basic_block_def*)
    ../../gcc-trunk/gcc/shrink-wrap.c:337
0x89abeb try_shrink_wrapping(edge_def**, edge_def*, bitmap_head*, rtx_def*)
    ../../gcc-trunk/gcc/shrink-wrap.c:463
0x6c5a51 thread_prologue_and_epilogue_insns
    ../../gcc-trunk/gcc/function.c:5661
0x6c5a51 rest_of_handle_thread_prologue_and_epilogue
    ../../gcc-trunk/gcc/function.c:6213
0x6c5a51 execute
    ../../gcc-trunk/gcc/function.c:6252
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <http://gcc.gnu.org/bugs.html> for instructions.
lto-wrapper: gcc-trunk returned 1 exit status
/usr/bin/ld: fatal error: lto-wrapper failed
collect2: error: ld returned 1 exit status
$ 
$ 
$ cat foo.c
static unsigned int
fn1 (int p1, int p2)
{
  return 0;
}

char a, b, c; 

char
foo (char *p)
{
  int i;
  for (b = 1 ; b > 0; b++) 
    {
      for (i = 0; i < 2; i++)
    ;
      for (a = 1; a > 0; a++)
    {
      char d[1] = { 0 };
      if (*p)
        break;
      c ^= fn1 (fn1 (fn1 (0, 0), 0), 0);
    }
    }
  return 0;
}
$ cat main.c
extern char foo (char *); 

char d; 

int
main ()
{
  foo (&d); 
  return 0;
}
$
>From gcc-bugs-return-452211-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Thu May 22 02:12:48 2014
Return-Path: <gcc-bugs-return-452211-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 16652 invoked by alias); 22 May 2014 02:12:46 -0000
Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm
Precedence: bulk
List-Id: <gcc-bugs.gcc.gnu.org>
List-Archive: <http://gcc.gnu.org/ml/gcc-bugs/>
List-Post: <mailto:gcc-bugs@gcc.gnu.org>
List-Help: <mailto:gcc-bugs-help@gcc.gnu.org>
Sender: gcc-bugs-owner@gcc.gnu.org
Delivered-To: mailing list gcc-bugs@gcc.gnu.org
Received: (qmail 16477 invoked by uid 48); 22 May 2014 02:12:38 -0000
From: "asolokha at gmx dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug tree-optimization/61279] New: [4.10 Regression] ICE in loop_preheader_edge, at cfgloop.c:1668 w/ -O1 -ftree-loop-vectorize
Date: Thu, 22 May 2014 02:12:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: new
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: tree-optimization
X-Bugzilla-Version: 4.10.0
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: asolokha at gmx dot com
X-Bugzilla-Status: UNCONFIRMED
X-Bugzilla-Priority: P3
X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org
X-Bugzilla-Target-Milestone: ---
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter
Message-ID: <bug-61279-4@http.gcc.gnu.org/bugzilla/>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: 7bit
X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/
Auto-Submitted: auto-generated
MIME-Version: 1.0
X-SW-Source: 2014-05/txt/msg01903.txt.bz2
Content-length: 1008

https://gcc.gnu.org/bugzilla/show_bug.cgi?ida279

            Bug ID: 61279
           Summary: [4.10 Regression] ICE in loop_preheader_edge, at
                    cfgloop.c:1668 w/ -O1 -ftree-loop-vectorize
           Product: gcc
           Version: 4.10.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: asolokha at gmx dot com

gcc-4.10.0-alpha20140518 fails when compiling the following code w/
-ftree-loop-vectorize -O1 and above:

int z;
int d;

int
n(void)
{
  int s;
  int *q;
  for (s = 0; s < 1; ++s) {
    int b;
    for (d = 0; d < 1; ++d)
      return 0;
    for (b = 0; b < 1; ++b) {
      int o[1] = { 0 };
      q = &o[b];
    }
    for (z = 0; z < 1; ++z)
      return 0;
  }
  return *q;
}

bb234e61.c: In function 'n':
bb234e61.c:21:1: internal compiler error: in loop_preheader_edge, at
cfgloop.c:1668

4.10.0-alpha20140411 works well here.


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

* [Bug tree-optimization/61277] Incorrect -Warray-bounds warning with 4.9.0
  2014-05-22  0:06 [Bug tree-optimization/61277] New: Incorrect -Warray-bounds warning with 4.9.0 akruppa at gmail dot com
@ 2021-08-08  3:20 ` pinskia at gcc dot gnu.org
  0 siblings, 0 replies; 2+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-08-08  3:20 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61277

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |4.9.3
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|---                         |FIXED

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
So this was fixed by r5-6842 which was backported for GCC 4.9.3 also.

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

end of thread, other threads:[~2021-08-08  3:20 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-05-22  0:06 [Bug tree-optimization/61277] New: Incorrect -Warray-bounds warning with 4.9.0 akruppa at gmail dot com
2021-08-08  3:20 ` [Bug tree-optimization/61277] " pinskia at gcc dot gnu.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).