The following testcase causes an ICE.  It is simply gcc.dg/980502-1.c
invoked with a different set of options, in particular, -fno-tree-dce.
Also included is the output of the final ccp pass.  Notice the (dead)
assignment '88 = 1'.  It looks like 'line[8]' in an lvalue context was
incorrectly folded to an rvalue.  I believe that the RTL phases choke on
this when DCE is not allowed to eliminate it.  I produced the output
below using trunk, but the issue shows up in 4.0.3 and probably elsewhere.

--- Contents of file 980502-1.c ---

char *const f(void)
{
        char *const line = "/dev/ptyXX";
        line[8] = 1;
        return line;
}

--- Failing compilation command ---

 ../rel/bin/gcc -v -save-temps  -c -O2 -fdump-tree-ccp -fno-tree-dce 980502-1.c
Using built-in specs.
Target: i686-pc-linux-gnu
Configured with: ../gcc/configure --with-gmp=/home/maddox/GCCLIBS
--with-mpfr=/home/maddox/GCCLIBS --build=i686-pc-linux-gnu
--host=i686-pc-linux-gnu --target=i686-pc-linux-gnu
--prefix=/home/maddox/trunk/rel --disable-bootstrap --disable-libmudflap
--disable-libgomp --enable-checking=yes,types
Thread model: posix
gcc version 4.4.0 20080304 (experimental) (GCC)
COLLECT_GCC_OPTIONS='-v' '-save-temps' '-c' '-O2' '-fdump-tree-ccp'
'-fno-tree-dce' '-mtune=generic'
 /home/maddox/trunk/rel/libexec/gcc/i686-pc-linux-gnu/4.4.0/cc1 -E -quiet -v
980502-1.c -mtune=generic -fdump-tree-ccp -fno-tree-dce -O2 -fpch-preprocess -o
980502-1.i
ignoring nonexistent directory
"/home/maddox/trunk/rel/lib/gcc/i686-pc-linux-gnu/4.4.0/../../../../i686-pc-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/local/include
 /home/maddox/trunk/rel/include
 /home/maddox/trunk/rel/lib/gcc/i686-pc-linux-gnu/4.4.0/include
 /home/maddox/trunk/rel/lib/gcc/i686-pc-linux-gnu/4.4.0/include-fixed
 /usr/include
End of search list.
COLLECT_GCC_OPTIONS='-v' '-save-temps' '-c' '-O2' '-fdump-tree-ccp'
'-fno-tree-dce' '-mtune=generic'
 /home/maddox/trunk/rel/libexec/gcc/i686-pc-linux-gnu/4.4.0/cc1 -fpreprocessed
980502-1.i -quiet -dumpbase 980502-1.c -mtune=generic -auxbase 980502-1 -O2
-version -fdump-tree-ccp -fno-tree-dce -o 980502-1.s
GNU C (GCC) version 4.4.0 20080304 (experimental) (i686-pc-linux-gnu)
        compiled by GNU C version 4.0.3 (Ubuntu 4.0.3-1ubuntu5), GMP version
4.2.1, MPFR version 2.2.1.
GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096
Compiler executable checksum: b487bd365f366d1cb315758fb9e38dc9
980502-1.c: In function 'f':
980502-1.c:7: internal compiler error: in simplify_subreg, at
simplify-rtx.c:4936
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instructions.

--- Contents of dump file 980502-1.c.056t.ccp2 ---

;; Function f (f)

f ()
{
<bb 2>:
  88 = 1;
  return &"/dev/ptyXX"[0];

}


-- 
           Summary: LHS of assignment can be folded to a constant causing
                    ICE
           Product: gcc
           Version: 4.3.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: maddox at gcc dot gnu dot org
 GCC build triplet: i686-pc-linux-gnu
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu


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

Reply via email to