public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/60111] New: [SH] ICE compiling Newlib (4.8.2)
@ 2014-02-07 21:25 lsebald1 at umbc dot edu
  2014-02-08 20:07 ` [Bug target/60111] [SH] ICE compiling Newlib olegendo at gcc dot gnu.org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: lsebald1 at umbc dot edu @ 2014-02-07 21:25 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 60111
           Summary: [SH] ICE compiling Newlib (4.8.2)
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: lsebald1 at umbc dot edu

Created attachment 32081
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=32081&action=edit
Preprocessed source file exhibiting the ICE.

When building a cross-compiler from armv6l-unknown-linux-gnueabihf (A Raspberry
Pi running Raspbian) to sh-elf, I'm running into an internal compiler error
when compiling part of Newlib. Here is the backtrace that is generated:

sh-elf-gcc
-B/mnt/usbhdd1/toolchain/kos/utils/dc-chain/build-newlib-sh-elf-2.0.0/sh-elf/m4-nofpu/newlib/
-isystem
/mnt/usbhdd1/toolchain/kos/utils/dc-chain/build-newlib-sh-elf-2.0.0/sh-elf/m4-nofpu/newlib/targ-include
-isystem
/mnt/usbhdd1/toolchain/kos/utils/dc-chain/newlib-2.0.0/newlib/libc/include
-B/mnt/usbhdd1/toolchain/kos/utils/dc-chain/build-newlib-sh-elf-2.0.0/sh-elf/m4-nofpu/libgloss/sh
-L/mnt/usbhdd1/toolchain/kos/utils/dc-chain/build-newlib-sh-elf-2.0.0/sh-elf/m4-nofpu/libgloss/libnosys
-L/mnt/usbhdd1/toolchain/kos/utils/dc-chain/newlib-2.0.0/libgloss/sh  -m4-nofpu
-DPACKAGE_NAME=\"newlib\" -DPACKAGE_TARNAME=\"newlib\"
-DPACKAGE_VERSION=\"2.0.0\" -DPACKAGE_STRING=\"newlib\ 2.0.0\"
-DPACKAGE_BUGREPORT=\"\" -DPACKAGE_URL=\"\" -I.
-I../../../../../../newlib-2.0.0/newlib/libc/stdlib
-DREENTRANT_SYSCALLS_PROVIDED -DMALLOC_PROVIDED -DABORT_PROVIDED -DHAVE_FCNTL
-ffunction-sections -fdata-sections -fno-builtin      -g -O2  -m4-nofpu -c -o
lib_a-lrand48.o `test -f 'lrand48.c' || echo
'../../../../../../newlib-2.0.0/newlib/libc/stdlib/'`lrand48.c
../../../../../../newlib-2.0.0/newlib/libc/stdlib/lrand48.c: In function
‘_lrand48_r’:
../../../../../../newlib-2.0.0/newlib/libc/stdlib/lrand48.c:24:1: internal
compiler error: in gen_ashift, at config/sh/sh.c:3746
 }
 ^
0x5a33db gen_ashift
    ../../gcc-4.8.2/gcc/config/sh/sh.c:3746
0x5a358f gen_shifty_hi_op(int, rtx_def**)
    ../../gcc-4.8.2/gcc/config/sh/sh.c:3874
0x5a87ff gen_shl_and(rtx_def*, rtx_def*, rtx_def*, rtx_def*)
    ../../gcc-4.8.2/gcc/config/sh/sh.c:4185
0x5f105f gen_split_912(rtx_def*, rtx_def**)
    ../../gcc-4.8.2/gcc/config/sh/sh.md:5173
0x222a6f try_split(rtx_def*, rtx_def*, int)
    ../../gcc-4.8.2/gcc/emit-rtl.c:3562
0x382b47 split_insn
    ../../gcc-4.8.2/gcc/recog.c:2836
0x38709f split_all_insns()
    ../../gcc-4.8.2/gcc/recog.c:2926
0x38715b rest_of_handle_split_after_reload
    ../../gcc-4.8.2/gcc/recog.c:3832
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.

I have tried with both GCC versions available on the host OS' package manager
(Debian 4.6.3-14+rpi1, and Debian 4.7.2-5+rpi1) and have the same ICE with both
of them. This may actually be a host-related bug, rather than a target-related
bug, as the ICE does not occur when building a cross-compiler on Darwin on
x86-64.

Preprocessed source code of the file exhibiting the ICE is attached.
>From gcc-bugs-return-442999-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Fri Feb 07 21:35:24 2014
Return-Path: <gcc-bugs-return-442999-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 3822 invoked by alias); 7 Feb 2014 21:35:24 -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 3782 invoked by uid 48); 7 Feb 2014 21:35:20 -0000
From: "david.abdurachmanov at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/60112] New: bogus error: array subscript is above array bounds
Date: Fri, 07 Feb 2014 21:35:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: new
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: c++
X-Bugzilla-Version: 4.9.0
X-Bugzilla-Keywords:
X-Bugzilla-Severity: minor
X-Bugzilla-Who: david.abdurachmanov at gmail 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-60112-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-02/txt/msg00756.txt.bz2
Content-length: 2731

http://gcc.gnu.org/bugzilla/show_bug.cgi?id`112

            Bug ID: 60112
           Summary: bogus error: array subscript is above array bounds
           Product: gcc
           Version: 4.9.0
            Status: UNCONFIRMED
          Severity: minor
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: david.abdurachmanov at gmail dot com

GCC pre-4.9.0 (r206686), no issues on 4.6.2, 4.7.2, and 4.8.1. I found that if
I mark `get_size' as inline or constexpr errors are gone. If I keep `nFaces'
uninitialized it also complains, but if I set it explicitly to some number
(e.g., 0,..,<max>) it's fine. Even commenting out such line (49) as

    lp += VV(tanDistToFace[iFDest]);

removes the errors.

I tried removing more mass from the test case, but it also removes the errors.

Doesn't work with -O2, but works fine with -O0, -O1, -O3, -Os, and -Og.

### COMPILE ###

c++ -c -O2 -std=c++11 -Werror=array-bounds -fdiagnostics-show-option -fPIC
test2.cpp

### ERRORS ###

test2.cpp: In function 'void abc()':
test2.cpp:43:37: error: array subscript is above array bounds
[-Werror=array-bounds]
     iFDestSorted[nDestSorted - i - 1] = iFDestSorted[iMax];
                                     ^
test2.cpp:44:22: error: array subscript is above array bounds
[-Werror=array-bounds]
     iFDestSorted[iMax] = iTmp;
                      ^
cc1plus: some warnings being treated as errors

### TEST CASE ###

struct GP {
  double mx, my, mz;
  GP (double x, double y, double z) : mx(x), my(y), mz(z) { };
};
typedef struct GP GP;

void do_something(const GP& n) { }

struct VV {
  double mx;
  VV (double x) : mx(x) { };
};
typedef struct VV VV;

struct PP {
  double mx;
  PP (double x) : mx(x) { };
  double x() { return mx; };
  PP& operator+=(const VV& rhs) { mx += rhs.mx; return *this; };
};
typedef struct PP PP;

int get_size() { return 0; };

void abc() {
  double tanDistToFace[6] = {0,0,0,0,0,0};
  unsigned int iFDestSorted[6] = {0,0,0,0,0,0};
  unsigned int nDestSorted = 0;

  unsigned int nFaces = get_size();
  for (unsigned int iFace = 0; iFace < nFaces; ++iFace) {
    nDestSorted++;
  }

  for (unsigned int i = 0; i < nDestSorted; ++i) {
    unsigned int iMax = nDestSorted - i - 1;
    for (unsigned int j=0; j < nDestSorted-i; ++j) {
      if (tanDistToFace[iFDestSorted[j]] > tanDistToFace[iFDestSorted[iMax]]) {
        iMax = j;
      }
    }
    unsigned int iTmp = iFDestSorted[nDestSorted - i - 1];
    iFDestSorted[nDestSorted - i - 1] = iFDestSorted[iMax];
    iFDestSorted[iMax] = iTmp;
  }

    int iFDest = iFDestSorted[0];
    PP lp(0);
    lp += VV(tanDistToFace[iFDest]);
    GP gp(lp.x(), lp.x(), lp.x());
    do_something(gp);
}


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

* [Bug target/60111] [SH] ICE compiling Newlib
  2014-02-07 21:25 [Bug target/60111] New: [SH] ICE compiling Newlib (4.8.2) lsebald1 at umbc dot edu
@ 2014-02-08 20:07 ` olegendo at gcc dot gnu.org
  2014-03-01 14:56 ` olegendo at gcc dot gnu.org
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: olegendo at gcc dot gnu.org @ 2014-02-08 20:07 UTC (permalink / raw)
  To: gcc-bugs

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

Oleg Endo <olegendo at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |olegendo at gcc dot gnu.org

--- Comment #1 from Oleg Endo <olegendo at gcc dot gnu.org> ---
Interesting.  Maybe PR 59375 is related somehow.


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

* [Bug target/60111] [SH] ICE compiling Newlib
  2014-02-07 21:25 [Bug target/60111] New: [SH] ICE compiling Newlib (4.8.2) lsebald1 at umbc dot edu
  2014-02-08 20:07 ` [Bug target/60111] [SH] ICE compiling Newlib olegendo at gcc dot gnu.org
@ 2014-03-01 14:56 ` olegendo at gcc dot gnu.org
  2014-11-20 16:03 ` segher at gcc dot gnu.org
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: olegendo at gcc dot gnu.org @ 2014-03-01 14:56 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Oleg Endo <olegendo at gcc dot gnu.org> ---
In gen_ashift the assert
    gcc_assert (satisfies_constraint_P27 (n_rtx));

fires, which means that the requested shift amount is not 1, 2, 8 or 16.

In gen_shifty_hi_op the function gen_ashift is invoked with the shift amount
values taken from the ext_ashl_lshr_seq table, which contains the allowed shift
amounts only.
I don't see a problem in sh.c.  Maybe it's a indeed a problem of the host
compiler.


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

* [Bug target/60111] [SH] ICE compiling Newlib
  2014-02-07 21:25 [Bug target/60111] New: [SH] ICE compiling Newlib (4.8.2) lsebald1 at umbc dot edu
  2014-02-08 20:07 ` [Bug target/60111] [SH] ICE compiling Newlib olegendo at gcc dot gnu.org
  2014-03-01 14:56 ` olegendo at gcc dot gnu.org
@ 2014-11-20 16:03 ` segher at gcc dot gnu.org
  2014-11-22  4:46 ` olegendo at gcc dot gnu.org
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: segher at gcc dot gnu.org @ 2014-11-20 16:03 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Segher Boessenkool <segher at gcc dot gnu.org> ---
Author: segher
Date: Thu Nov 20 16:03:16 2014
New Revision: 217883

URL: https://gcc.gnu.org/viewcvs?rev=217883&root=gcc&view=rev
Log:
2014-11-20  Segher Boessenkool  <segher@kernel.crashing.org>

    PR target/60111
    * config/sh/sh.c: Use signed char for signed field.

Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/config/sh/sh.c


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

* [Bug target/60111] [SH] ICE compiling Newlib
  2014-02-07 21:25 [Bug target/60111] New: [SH] ICE compiling Newlib (4.8.2) lsebald1 at umbc dot edu
                   ` (2 preceding siblings ...)
  2014-11-20 16:03 ` segher at gcc dot gnu.org
@ 2014-11-22  4:46 ` olegendo at gcc dot gnu.org
  2014-11-22  4:53 ` olegendo at gcc dot gnu.org
  2014-11-22  4:55 ` olegendo at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: olegendo at gcc dot gnu.org @ 2014-11-22  4:46 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Oleg Endo <olegendo at gcc dot gnu.org> ---
Author: olegendo
Date: Sat Nov 22 04:45:46 2014
New Revision: 217958

URL: https://gcc.gnu.org/viewcvs?rev=217958&root=gcc&view=rev
Log:
gcc/
    Backport from mainline
    2014-11-20  Segher Boessenkool  <segher@kernel.crashing.org>

    PR target/60111
    * config/sh/sh.c: Use signed char for signed field.

Modified:
    branches/gcc-4_9-branch/gcc/ChangeLog
    branches/gcc-4_9-branch/gcc/config/sh/sh.c


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

* [Bug target/60111] [SH] ICE compiling Newlib
  2014-02-07 21:25 [Bug target/60111] New: [SH] ICE compiling Newlib (4.8.2) lsebald1 at umbc dot edu
                   ` (3 preceding siblings ...)
  2014-11-22  4:46 ` olegendo at gcc dot gnu.org
@ 2014-11-22  4:53 ` olegendo at gcc dot gnu.org
  2014-11-22  4:55 ` olegendo at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: olegendo at gcc dot gnu.org @ 2014-11-22  4:53 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from Oleg Endo <olegendo at gcc dot gnu.org> ---
Author: olegendo
Date: Sat Nov 22 04:52:46 2014
New Revision: 217959

URL: https://gcc.gnu.org/viewcvs?rev=217959&root=gcc&view=rev
Log:
gcc/
    Backport from mainline
    2014-11-20  Segher Boessenkool  <segher@kernel.crashing.org>

    PR target/60111
    * config/sh/sh.c: Use signed char for signed field.

Modified:
    branches/gcc-4_8-branch/gcc/ChangeLog
    branches/gcc-4_8-branch/gcc/config/sh/sh.c


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

* [Bug target/60111] [SH] ICE compiling Newlib
  2014-02-07 21:25 [Bug target/60111] New: [SH] ICE compiling Newlib (4.8.2) lsebald1 at umbc dot edu
                   ` (4 preceding siblings ...)
  2014-11-22  4:53 ` olegendo at gcc dot gnu.org
@ 2014-11-22  4:55 ` olegendo at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: olegendo at gcc dot gnu.org @ 2014-11-22  4:55 UTC (permalink / raw)
  To: gcc-bugs

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

Oleg Endo <olegendo at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|---                         |FIXED

--- Comment #6 from Oleg Endo <olegendo at gcc dot gnu.org> ---
Fixed on trunk, 4.9 and 4.8.


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

end of thread, other threads:[~2014-11-22  4:55 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-02-07 21:25 [Bug target/60111] New: [SH] ICE compiling Newlib (4.8.2) lsebald1 at umbc dot edu
2014-02-08 20:07 ` [Bug target/60111] [SH] ICE compiling Newlib olegendo at gcc dot gnu.org
2014-03-01 14:56 ` olegendo at gcc dot gnu.org
2014-11-20 16:03 ` segher at gcc dot gnu.org
2014-11-22  4:46 ` olegendo at gcc dot gnu.org
2014-11-22  4:53 ` olegendo at gcc dot gnu.org
2014-11-22  4:55 ` olegendo 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).