This is the mail archive of the
gcc-prs@gcc.gnu.org
mailing list for the GCC project.
c/8960: [3.2/3.3 regression] Segfault with __attribute__ ((mode (...))) in start_function:5702
- From: Christian Ehrhardt <ehrhardt at mathematik dot uni-ulm dot de>
- To: gcc-gnats at gcc dot gnu dot org
- Date: 16 Dec 2002 14:32:54 -0000
- Subject: c/8960: [3.2/3.3 regression] Segfault with __attribute__ ((mode (...))) in start_function:5702
- Reply-to: Christian Ehrhardt <ehrhardt at mathematik dot uni-ulm dot de>
>Number: 8960
>Category: c
>Synopsis: [3.2/3.3 regression] Segfault with __attribute__ ((mode (...))) in start_function:5702
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: unassigned
>State: open
>Class: ice-on-legal-code
>Submitter-Id: net
>Arrival-Date: Mon Dec 16 06:36:04 PST 2002
>Closed-Date:
>Last-Modified:
>Originator: Christian Ehrhardt
>Release: 3.2.2, 3.3
>Organization:
>Environment:
Mostly arch and version independant, but tested with this:
Reading specs from gcc-install/bin/../lib/gcc-lib/sparc-sun-solaris2.9/3.3/specs
Configured with: /home/thales/ehrhardt/gcc-cvs/gcc/configure --with-ld=/usr/local/bin/ld --with-as=/usr/local/bin/as --with-gnu-as --with-gnu-ld --enable-languages=c,c++ : (reconfigured) /home/thales/ehrhardt/gcc-cvs/gcc/configure --with-ld=/usr/local/bin/ld --with-as=/usr/local/bin/as --with-gnu-as --with-gnu-ld --enable-languages=c,c++ --prefix=/home/thales/ehrhardt/gcc-install/
Thread model: posix
gcc version 3.3 20021204 (experimental)
SunOS theseus 5.9 Generic_112233-02 sun4u sparc SUNW,Ultra-4
>Description:
This piece of code ICEs on virtually any 3.2 or 3.3 compiler and
on both sun-sparc-solaris and i386.
--------------------- cut --------------------
__attribute__ ((mode (SI)))
int f () { }
--------------------- cut --------------------
x.c:2: internal compiler error: Segmentation Fault
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://www.gnu.org/software/gcc/bugs.html> for instructions.
The segfault is in this piece of code in start_function:
if (!COMPLETE_OR_VOID_TYPE_P (TREE_TYPE (TREE_TYPE (decl1))))
{
error ("return type is an incomplete type");
/* Make it return void instead. */
TREE_TYPE (decl1)
= build_function_type (void_type_node,
TYPE_ARG_TYPES (TREE_TYPE (decl1)));
}
The real problem seems to be when applying attributs. gdb shows that
the following happens in start_function:
grokdeclarator creates a proper function declaration with return type int
in decl1. Afterwards decl_attributes is called to apply the mode attribute
to the function declaration. decl_attributes properly detects that the
mode attribute doesn't apply to a declaration but a type. The mistake is
that the attribute is then applied to the function type. This will
replace the function type with an SImode integer type.
Thus f becomes a function declaration with a type "int" instead of
"function returning int". This results in an ICE a few instructions
later.
regards Christian
>How-To-Repeat:
See description. Just compile the sample code with any 3.x compiler.
2.95.3 is fine.
>Fix:
Using a typedef for the return type fixes the ice but be aware that there
is another probably unrelated bug (PR 7227) which is about bad code
generation with some modes.
>Release-Note:
>Audit-Trail:
>Unformatted: