Bug 8788 - ICE in emit_move_insn, at expr.c:3089
Summary: ICE in emit_move_insn, at expr.c:3089
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: inline-asm (show other bugs)
Version: 3.2.1
: P3 normal
Target Milestone: 4.1.0
Assignee: Not yet assigned to anyone
URL:
Keywords: ice-on-invalid-code
: 9233 11896 12530 15131 15136 20818 21811 26077 28529 (view as bug list)
Depends on:
Blocks:
 
Reported: 2002-12-02 09:26 UTC by killer.lightspeed
Modified: 2006-07-28 23:48 UTC (History)
10 users (show)

See Also:
Host:
Target: i?86-*-*
Build:
Known to work:
Known to fail:
Last reconfirmed: 2005-02-14 02:04:28


Attachments
Example: Referring a struct from inline assembler w/ workaround (1.08 KB, text/plain)
2004-05-12 08:09 UTC, Mogens Dybæk Christensen
Details

Note You need to log in before you can comment on or make changes to this bug.
Description killer.lightspeed 2002-12-02 09:26:01 UTC
GCC encounters an internal compiler error instead of reporting an error when it encounters an attempt to fit a 192-bit structure into a 32-bit register.

E:\DJGPP\bugs>gcc -v -save-temps -c test2.c
Reading specs from e:/djgpp/lib/gcc-lib/djgpp/3.21/specs
Configured with: /devel/gnu/gcc/3.2/gnu/gcc-3.21/configure i586-pc-msdosdjgpp --prefix=/dev/env/DJDIR --disable-nls
Thread model: single
gcc version 3.2.1
 e:/djgpp/lib/gcc-lib/djgpp/3.21/cpp0.exe -lang-c -v -D__GNUC__=3 -D__GNUC_MINOR__=2 -D__GNUC_PATCHLEVEL__=1 -D__GXX_ABI_VERSION=102 -D__MSDOS__ -D__GO32__ -D__DJGPP__=2 -D__unix__ -D__MSDOS__ -D__GO32__ -D__DJGPP__=2 -D__unix__ -Asystem=msdos -Asystem=unix -D__NO_INLINE__ -D__STDC_HOSTED__=1 -Acpu=i386 -Amachine=i386 -Di386 -D__i386 -D__i386__ -D__tune_i586__ -D__tune_pentium__ -DMSDOS -DGO32 -DDJGPP=2 -Dunix -remap -imacros e:/djgpp/lib/gcc-lib/djgpp/3.21/djgpp.ver test2.c test2.i
GNU CPP version 3.2.1 (cpplib) (80386, BSD syntax)
ignoring nonexistent directory "e:/djgpp/djgpp/include"
#include "..." search starts here:
#include <...> search starts here:
 e:/djgpp/lib/gcc-lib/djgpp/3.21/include
 e:/djgpp/include
End of search list.
 e:/djgpp/lib/gcc-lib/djgpp/3.21/cc1.exe -fpreprocessed test2.i -quiet -dumpbase test2.c -version -o test2.s
GNU CPP version 3.2.1 (cpplib) (80386, BSD syntax)
GNU C version 3.2.1 (djgpp)
	compiled by GNU C version 3.2.1.
test2.c: In function `switch_to_stack':
test2.c:10: Internal compiler error in emit_move_insn, at expr.c:2771
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://www.gnu.org/software/gcc/bugs.html> for instructions.

Release:
gcc version 3.2.1

Environment:
OS: Windows 98 [Version 4.10.2222]
CPU: AuthenticAMD AMD-K6(tm) 3D processor
RAM: 160.0MB RAM
Distribution: MS-DOS DJGPP v2

How-To-Repeat:
Invoked with:
gcc -v -save-temps -c test2.c
Preprocessed source (test2.i):
# 1 "test2.c"
# 1 "<built-in>"
# 1 "<command line>"
# 1 "e:/djgpp/lib/gcc-lib/djgpp/3.21/djgpp.ver" 1
# 1 "e:/djgpp/include/sys/version.h" 1 3
# 2 "e:/djgpp/lib/gcc-lib/djgpp/3.21/djgpp.ver" 2
# 2 "<command line>" 2
# 1 "test2.c"
typedef struct {
    long x[6];
} myjmp_buf;

typedef struct {
    myjmp_buf regs;
} my_stack;

void switch_to_stack (my_stack *stack){
    asm (
        "\n"
        : "+a" (stack->regs)
    );
}
Comment 1 Wolfgang Bangerth 2002-12-02 13:32:47 UTC
State-Changed-From-To: open->analyzed
State-Changed-Why: Confirmed. Also happens on Linux and with all versions
    of gcc since at least 2.95
Comment 2 Andrew Pinski 2003-05-29 17:39:14 UTC
moving to inline-asm because that is where it belongs.
Comment 3 Andrew Pinski 2003-07-11 20:37:39 UTC
This does not ICE but  gives "inconsistent operand constraints in an `asm'" in 2.91.66 so 
this is a regression with respect to that, it happens in 2.95.3 also so it was introduced in 
between.
Comment 4 Andrew Pinski 2003-07-11 23:36:46 UTC
This happens on all i?86-*-*.
Comment 5 Andrew Pinski 2003-07-13 19:53:54 UTC
Since this is an ice-on-invalid-code regression moving target to 3.3.2.
Comment 6 Falk Hueffner 2003-08-18 19:40:56 UTC
This happens with any struct that has more than one element:

void f(){
    struct { char x, y; } s;
    asm ("" : : "r" (s));
}

The documentation is not quite clear about what's legal here, I think it would  
be best to document that one-element structs are OK for "r" (because people are  
likely using that at the moment), and reject all other structs with a useful  
error message.
Comment 7 Falk Hueffner 2003-08-18 19:41:30 UTC
*** Bug 9233 has been marked as a duplicate of this bug. ***
Comment 8 Falk Hueffner 2003-08-18 19:41:52 UTC
*** Bug 11896 has been marked as a duplicate of this bug. ***
Comment 9 Andrew Pinski 2003-10-06 21:11:58 UTC
*** Bug 12530 has been marked as a duplicate of this bug. ***
Comment 10 Mark Mitchell 2003-10-16 02:40:43 UTC
Postponed until GCC 3.3.3.
Comment 11 Eric Botcazou 2003-12-12 09:48:37 UTC
It fails in GCC 2.95.x and all 3.x releases and I think it is not worth while to
tweak the middle-end on a release branch for such a pathological case.
Comment 12 Andrew Pinski 2003-12-20 08:36:24 UTC
A regression from 2.91 is not really worth being mentioned as this is an ice-on-invalid-
code.
Comment 13 Falk Hueffner 2004-04-25 15:53:03 UTC
*** Bug 15131 has been marked as a duplicate of this bug. ***
Comment 14 Andrew Pinski 2004-04-25 17:30:45 UTC
*** Bug 15136 has been marked as a duplicate of this bug. ***
Comment 15 Mogens Dybæk Christensen 2004-05-12 08:09:58 UTC
Created attachment 6262 [details]
Example: Referring a struct from inline assembler w/ workaround

This simplified code produces "Internal Compiler Error" on gcc 3.3.1/cygwin
(and other versions). The bug is present also when renaming and compiling the
file as C++.

A possible workaround seems to be adding '&' in the macro invocation, which
also seems more correct, since this is about passing a pointer in a register.
Comment 16 Andrew Pinski 2005-04-08 06:26:21 UTC
*** Bug 20818 has been marked as a duplicate of this bug. ***
Comment 17 GCC Commits 2005-05-09 05:16:00 UTC
Subject: Bug 8788

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	sayle@gcc.gnu.org	2005-05-09 05:15:51

Modified files:
	gcc            : ChangeLog stmt.c 
	gcc/testsuite  : ChangeLog 
Added files:
	gcc/testsuite/gcc.dg: pr8788-1.c 

Log message:
	PR inline-asm/8788
	* stmt.c (expand_asm_operands): Avoid calling force_reg on BLKmode
	operands.
	
	* gcc.dg/pr8788-1.c: New testcase.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&r1=2.8666&r2=2.8667
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/stmt.c.diff?cvsroot=gcc&r1=1.421&r2=1.422
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.5447&r2=1.5448
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.dg/pr8788-1.c.diff?cvsroot=gcc&r1=NONE&r2=1.1

Comment 18 Andrew Pinski 2005-05-29 23:48:14 UTC
*** Bug 21811 has been marked as a duplicate of this bug. ***
Comment 19 Andrew Pinski 2005-05-29 23:48:42 UTC
Fixed on the mainline for 4.1.0.
Comment 20 Andrew Pinski 2006-02-02 17:13:40 UTC
*** Bug 26077 has been marked as a duplicate of this bug. ***
Comment 21 Andrew Pinski 2006-07-28 23:48:29 UTC
*** Bug 28529 has been marked as a duplicate of this bug. ***