Bug 32589 - [4.3 regression] exp_dbug.adb:981: error: invalid array index
Summary: [4.3 regression] exp_dbug.adb:981: error: invalid array index
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: tree-optimization (show other bugs)
Version: 4.3.0
: P3 normal
Target Milestone: 4.3.0
Assignee: Eric Botcazou
URL: http://gcc.gnu.org/ml/gcc-patches/200...
Keywords: build, ice-on-valid-code
: 32675 (view as bug list)
Depends on:
Blocks: 32713
  Show dependency treegraph
 
Reported: 2007-07-02 17:02 UTC by John David Anglin
Modified: 2007-07-13 07:27 UTC (History)
6 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2007-07-02 21:44:38


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description John David Anglin 2007-07-02 17:02:48 UTC
/test/gnu/gcc/objdir/./prev-gcc/xgcc -B/test/gnu/gcc/objdir/./prev-gcc/ -B/opt/g
nu/gcc/gcc-4.3.0/hppa2.0w-hp-hpux11.11/bin/ -c -g -O2 -mdisable-indexing     -gn
atpg -gnata -nostdinc -I- -I. -Iada -I../../gcc/gcc/ada ../../gcc/gcc/ada/exp_db
ug.adb -o ada/exp_dbug.o
../../gcc/gcc/ada/exp_dbug.adb: In function 'Exp_Dbug.Prepend_String_To_Buffer':
../../gcc/gcc/ada/exp_dbug.adb:981: error: invalid array index
(<unnamed-signed:32>) MAX_EXPR <D.2719_31, 0> + 1;

+===========================GNAT BUG DETECTED==============================+
| 4.3.0 20070702 (experimental) (hppa2.0w-hp-hpux11.11) verify_stmts failed|
| Error detected around ../../gcc/gcc/ada/exp_dbug.adb:981                 |
| Please submit a bug report; see http://gcc.gnu.org/bugs.html.            |
| Use a subject line meaningful to you and us to track the bug.            |
| Include the entire contents of this bug box in the report.               |
| Include the exact gcc or gnatmake command that you entered.              |
| Also include sources listed below in gnatchop format                     |
| (concatenated together with no headers between files).                   |
+==========================================================================+

-bash-2.05b$ ./xgcc -B./ -v
Reading specs from ./specs
Target: hppa2.0w-hp-hpux11.11
Configured with: ../gcc/configure --with-gnu-as --with-as=/opt/gnu/bin/as --enable-shared --disable-nls --with-local-prefix=/opt/gnu --prefix=/opt/gnu/gcc/gcc-4.3.0 --enable-debug=no --enable-threads=posix --with-mpfr=/opt/gnu/gcc/gcc-4.3.0 --with-gmp=/opt/gnu/gcc/gcc-4.3.0 --disable-libmudflap --enable-languages=c,c++,objc,obj-c++,fortran,java,ada
Thread model: posix
gcc version 4.3.0 20070702 (experimental)
Comment 1 Eric Botcazou 2007-07-02 21:44:21 UTC
Present on x86 too (but not x86-64).
Comment 2 Eric Botcazou 2007-07-02 21:44:38 UTC
Investigating.
Comment 3 Eric Botcazou 2007-07-03 13:10:12 UTC
Reduced testcase:

package P is

   Name_Buffer : String (1 .. 100);
   Name_Len : Natural;

   procedure Proc (S : String);

end P;

package body P is

   procedure Proc (S : String) is
      N : constant Integer := S'Length;
   begin
      Name_Buffer (1 + N .. Name_Len + N) := Name_Buffer (1 .. Name_Len);
      Name_Buffer (1 .. N) := S;
      Name_Len := Name_Len + N;
   end;

end P;


Fallout of:

2007-06-30  Daniel Berlin  <dberlin@dberlin.org>
	
	Fix PR tree-optimization/32540
	Fix PR tree-optimization/31651

	* tree-ssa-sccvn.c: New file.

	* tree-ssa-sccvn.h: Ditto.


Value numbering D.759_64 stmt = D.759_64 = &p__name_buffer[1]{lb: 1 sz: 1} + n_32;
RHS &p__name_buffer[1]{lb: 1 sz: 1} + n_32 simplified to &p__name_buffer[(<unnamed-signed:32>) MAX_EXPR <D.738_31, 0> + 1]{lb: 1 sz: 1} has constants 0

The replacement expression is is_gimple_min_invariant because TREE_INVARIANT
so simplify_binary_expression accepts it:

  /* Make sure result is not a complex expression consiting
     of operators of operators (IE (a + b) + (a + c))
     Otherwise, we will end up with unbounded expressions if
     fold does anything at all.  */
  if (result)
    {
      if (is_gimple_min_invariant (result))
	return result;
      else if (SSA_VAR_P (result))
	return result;
Comment 4 Eric Botcazou 2007-07-03 22:26:39 UTC
Reclassifying.
Comment 5 Alexandre Oliva 2007-07-05 04:50:17 UTC
FWIW, I haven't been able to bootstrap on ppc64-linux-gnu after this patch went in.  I'm not sure I'd tried a full bootstrap before (I've only very recently got easy access to a ppc box), but the failure is bootstrap compare in a bunch of Ada files.  bootstrap4 didn't make much difference.  I'm trying ppc-linux-gnu now.
Comment 6 Eric Botcazou 2007-07-05 08:38:48 UTC
> FWIW, I haven't been able to bootstrap on ppc64-linux-gnu after this patch went
> in.  I'm not sure I'd tried a full bootstrap before (I've only very recently
> got easy access to a ppc box), but the failure is bootstrap compare in a bunch
> of Ada files.

It's unrelated to this patch, and apparently a PPC64-specific problem, see
  http://gcc.gnu.org/ml/gcc/2007-06/msg00784.html
Comment 7 Alexandre Oliva 2007-07-06 00:36:10 UTC
FWIW, ppc-linux-gnu bootstrap failed with the same tree, but reverting to before the 2007-06-30 patch it worked again.  ppc64-linux-gnu still failed.
Comment 8 Rob 2007-07-07 04:05:14 UTC
I searched the last 30 reports using http://gcc.gnu.org/bugzilla/buglist.cgi?product=gcc&version=4.3.0&chfieldfrom=2007-07-06&chfieldto=2007-07-07&chfieldvalue=&cmdtype=doit&order=Bug+Number to find the best place to put this comment.

When I compile with --enable-languages=...,ada,... I get the same error as reported here. I'm guessing that if this problem was not caused by 32004 or 32441 then it will be fixed here at 32589 :) .

When I compile with --enable-languages=c,c++,fortran,java,objc,obj-c++ (instead of including Ada), I get this error instead:

...
Configuring stage 3 in i686-pc-linux-gnu/libgcc
... (a thousand or so lines later)
make[4]: Leaving directory `/opt/gcc-4_3-build/i686-pc-linux-gnu/libgcc'
make[3]: Leaving directory `/opt/gcc-4_3-build/i686-pc-linux-gnu/libgcc'
make[2]: Leaving directory `/opt/gcc-4_3-build'
make "DESTDIR=" "RPATH_ENVVAR=LD_LIBRARY_PATH" "TARGET_SUBDIR=i686-pc-linux-gnu" ...
make[2]: Entering directory `/opt/gcc-4_3-build'
make[3]: Entering directory `/opt/gcc-4_3-build'
rm -f stage_current
make[3]: Leaving directory `/opt/gcc-4_3-build'
Comparing stages 2 and 3
warning: ./cc1-checksum.o differs
warning: ./cc1plus-checksum.o differs
warning: ./cc1obj-checksum.o differs
warning: ./cc1objplus-checksum.o differs
Bootstrap comparison failure!
./varasm.o differs
./i386.o differs
./gcc.o differs
./crtbeginS.o differs
./crtendS.o differs
make[2]: *** [compare] Error 1
make[2]: Leaving directory `/opt/gcc-4_3-build'
make[1]: *** [stage3-bubble] Error 2
make[1]: Leaving directory `/opt/gcc-4_3-build'
make: *** [all] Error 2

That is a BCF in excess of the warnings (that are permissable).
Comment 9 Eric Botcazou 2007-07-08 14:25:05 UTC
*** Bug 32675 has been marked as a duplicate of this bug. ***
Comment 10 Eric Botcazou 2007-07-11 09:43:35 UTC
Subject: Bug 32589

Author: ebotcazou
Date: Wed Jul 11 09:43:25 2007
New Revision: 126545

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=126545
Log:
	PR tree-optimization/32589
	* doc/tree-ssa.texi (Rough GIMPLE Grammar): Add missing rule.
	* tree-gimple.c (is_gimple_min_invariant): Clarify head comment.
	* tree-ssa-propagate.c (valid_gimple_expression_p): New
	predicate, extracted from...
	(set_rhs): ...here.  Call it for the expression on entry.
	* tree-ssa-propagate.h (valid_gimple_expression_p): Declare.
	* tree-ssa-sccvn.c: Include tree-ssa-propagate.h.
	(simplify_binary_expression): Use valid_gimple_expression_p
	to validate the simplification.
	* Makefile.in (tree-ssa-sccvn.o): Depends on tree-ssa-propagate.h.


Added:
    trunk/gcc/testsuite/gnat.dg/invariant_index.adb
    trunk/gcc/testsuite/gnat.dg/invariant_index.ads
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/Makefile.in
    trunk/gcc/doc/tree-ssa.texi
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/tree-gimple.c
    trunk/gcc/tree-ssa-propagate.c
    trunk/gcc/tree-ssa-propagate.h
    trunk/gcc/tree-ssa-sccvn.c

Comment 11 Eric Botcazou 2007-07-11 09:46:37 UTC
The compiler now bootstraps, but the library still doesn't build.
Comment 12 Rob 2007-07-12 00:55:34 UTC
I am building on target i686-pc-linux-gnu and have not noticed this problem with this target. It does NOT occur for a 'regular' "make", only seems to happen with this last "make profiledbootstrap" that I did:

We have a problem of 'doubling up the directories'. This _always_ occurs for platform i686-pc-cygwin as described here (with a FIX): http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30341

That means I have these directories when the build crashed:

/opt/gcc-4_3-build/stage1-gcc/stage1-gcc/
/opt/gcc-4_3-build/stage1-i686-pc-linux-gnu/stage1-i686-pc-linux-gnu/
/opt/gcc-4_3-build/stage1-intl/stage1-intl/
/opt/gcc-4_3-build/stage1-libcpp/stage1-libcpp/
/opt/gcc-4_3-build/stage1-libdecnumber/stage1-libdecnumber/
/opt/gcc-4_3-build/stage1-libiberty/stage1-libiberty/      
/opt/gcc-4_3-build/stage1-zlib/stage1-zlib/                

That wastes a huge amount of space if the makefiles are double building 
everything and not deleting (or merging) unused directories as it goes.

This is likely causing the BCF, the "*.gcda not found, execution counts estimated" problem, and other related errors.

You say "compiler now bootstraps", I hope that means the 'doubling' is fixed since it could knock out builds on smaller (or nearly full) HDs.


Comment 13 Eric Botcazou 2007-07-12 06:00:45 UTC
> We have a problem of 'doubling up the directories'. This _always_ occurs for
> platform i686-pc-cygwin as described here (with a FIX):
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30341

Please do not pollute this ticket with unrelated stuff.

> You say "compiler now bootstraps", I hope that means the 'doubling' is fixed
> since it could knock out builds on smaller (or nearly full) HDs.

No, it only means that the compiler now bootstraps.
Comment 14 Rob 2007-07-13 07:27:12 UTC
>Comment #13 From Eric Botcazou 2007-07-12 06:00 [reply] ------- 
>Please do not pollute this ticket with unrelated stuff.

I posted here after previously searching many messages, and again re-searching more messages to see if you had made a new ticket in regards to:

> ... but the library still doesn't build.

I only posted in relation to "the build being broken at this point". I thought the info was related and would assist you in your repairs to have the build work _completely_ at this point in time.

Thank you for fixing the portion that was fixed.