Bug 17676 - Problem with user operator
Summary: Problem with user operator
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 4.0.0
: P2 normal
Target Milestone: 4.0.0
Assignee: Not yet assigned to anyone
URL:
Keywords: ice-on-valid-code, patch
Depends on:
Blocks:
 
Reported: 2004-09-26 08:49 UTC by Eric Botcazou
Modified: 2004-10-08 00:22 UTC (History)
2 users (show)

See Also:
Host: sparc*-*-*
Target: sparc*-*-*
Build: sparc*-*-*
Known to work:
Known to fail:
Last reconfirmed: 2004-09-26 14:02:15


Attachments
Putative patch (349 bytes, patch)
2004-09-26 14:01 UTC, Tobias Schlüter
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Eric Botcazou 2004-09-26 08:49:18 UTC
We have the following failures on SPARC:

FAIL: gfortran.fortran-torture/execute/userop.f90 compilation,  -O0 
FAIL: gfortran.fortran-torture/execute/userop.f90 compilation,  -O1 
FAIL: gfortran.fortran-torture/execute/userop.f90 compilation,  -O2 
FAIL: gfortran.fortran-torture/execute/userop.f90 compilation,  -O3
-fomit-frame-pointer 
FAIL: gfortran.fortran-torture/execute/userop.f90 compilation,  -O3
-fomit-frame-pointer -funroll-loops 
FAIL: gfortran.fortran-torture/execute/userop.f90 compilation,  -O3
-fomit-frame-pointer -funroll-all-loops -finline-functions 
FAIL: gfortran.fortran-torture/execute/userop.f90 compilation,  -O3 -g 
FAIL: gfortran.fortran-torture/execute/userop.f90 compilation,  -Os 


The problem is at resolve.c:1418:
	sprintf (msg, "Operands of user operator '%s' at %%L are %s/%s",
		 e->uop->ns->proc_name->name, gfc_typename (&op1->ts),
		 gfc_typename (&op2->ts));

e->uop->ns->proc_name is NULL.  So an out-of-bounds address is passed to sprintf
and we get a SIGSEGV inside the libc.  Note that we don't get it with a
cross-compiler on Linux/x86, but the address is NULL there anyway.
Comment 1 Tobias Schlüter 2004-09-26 14:01:48 UTC
Created attachment 7220 [details]
Putative patch

Try this please. The original code looks like it is a relic from some past time
where operators kept their names in their own namespaces. I don't know if that
time ever existed.

2004-09-26  Tobias Schlueter  <tobias.schlueter@physik.uni-muenchen.de>

	PR fortran/17676
	* resolve.c (resolve_operator): Use correct operator name in message.
Comment 2 Eric Botcazou 2004-09-27 14:39:56 UTC
> Try this please. The original code looks like it is a relic from some past time
> where operators kept their names in their own namespaces. I don't know if that
> time ever existed.
> 
> 2004-09-26  Tobias Schlueter  <tobias.schlueter@physik.uni-muenchen.de>
> 
> 	PR fortran/17676
> 	* resolve.c (resolve_operator): Use correct operator name in message.

The patch fixes all the userop.f90 failures.  Thanks for the prompt response!
Comment 3 GCC Commits 2004-10-08 00:16:32 UTC
Subject: Bug 17676

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	tobi@gcc.gnu.org	2004-10-08 00:16:28

Modified files:
	gcc/fortran    : ChangeLog resolve.c 

Log message:
	PR fortran/17676
	* resolve.c (resolve_operator): Use correct operator name in message.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/fortran/ChangeLog.diff?cvsroot=gcc&r1=1.232&r2=1.233
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/fortran/resolve.c.diff?cvsroot=gcc&r1=1.19&r2=1.20

Comment 4 Tobias Schlüter 2004-10-08 00:18:17 UTC
Sorry, I forgot to actually submit this patch :( Applied as obvious after
re-testing. Fixed.