[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

GCC internal error in preprocessed C code



>Submitter-Id:	net
>Originator:	David Walker
>Organization:	Private Individual
>Confidential:	no
>Synopsis:	GCC internal error in preprocessed C code
>Severity:	serious
>Priority:	medium
>Category:	optimization
>Class:		ice-on-legal-code
>Release:	3.4.0 (base snapshot)
>Environment:
System: Linux mrbean 2.6.1 #1 Wed Jan 21 16:45:49 CST 2004 i686 GNU/Linux
Architecture: i686
    libc: 2.3.2.ds1-12 (Debian)
host: i686-pc-linux-gnu
build: i686-pc-linux-gnu
target: i686-pc-linux-gnu
Configured with: ./configure --enable-languages=c --enable-shared --with-system-zlib --enable-nls --without-included-gettext --enable-debug
>Description:
	GCC throws an internal compiler error on the following code when run with optimizations. Bug exists in 3.2, 3.3, and 3.4.
>How-To-Repeat:
Here's the command-line I ran with output:
davedude@mrbean:/usr/src/gcc-3.4.0/gcc$ ./xgcc -B. -v -O2 -fno-strict-aliasing ~/c/uiuc/cs348/mp6/bug.i
Reading specs from ./specs
Configured with: ./configure --enable-languages=c --enable-shared --with-system-zlib --enable-nls --without-included-gettext --enable-debug
Thread model: posix
gcc version 3.4.0
 ./cc1 -fpreprocessed /home/davedude/c/uiuc/cs348/mp6/bug.i -quiet -dumpbase bug.i -mtune=pentiumpro -auxbase bug -O2 -version -fno-strict-aliasing -o /tmp/ccOtjqJK.s
GNU C version 3.4.0 (i686-pc-linux-gnu)
        compiled by GNU C version 3.3.3 (Debian 20040401).
GGC heuristics: --param ggc-min-expand=47 --param ggc-min-heapsize=32090
bug.c: In function `main':
bug.c:20: error: insn does not satisfy its constraints:
(insn:HI 41 40 53 2 (set (reg/v:SI 3 bx [orig:74 y ] [74])
        (sign_extend:SI (mem/s/j:QI (mult:SI (plus:SI (reg/f:SI 6 bp)
                        (const_int -13 [0xfffffff3]))
                    (const_int 2 [0x2])) [0 dir S1 A8]))) 86 {extendqisi2} (nil)
    (nil))
bug.c:20: internal compiler error: in reload_cse_simplify_operands, at postreload.c:378
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://gcc.gnu.org/bugs.html> for instructions.

Here's bug.i:

# 1 "bug.c"
# 1 "<built-in>"
# 1 "<command line>"
# 1 "bug.c"
int globl;

void dummy(char arg)
{
    globl = arg;
}

int main(int argc, char *argv[])
{
    char dir[1];
    int y = 0, best;

    while (y > *argv[0])
    {
        best = (int)dir;
        y = dir[best];
        dummy(*argv[1|best]);
    }
    return 0;
}
>Fix:
	Bug only appears with optimizations on. Also, this is as small as I could make
	the bug. Most changes to the above code will remove the problem. Although the
	code is obviously artificial, the problem did crop up in real code originally.



Reply to: