public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/56284] New: ICE with contained routine which inappropriately compares a string and a number
@ 2013-02-11 8:58 arjen.markus at deltares dot nl
2013-02-11 9:02 ` [Bug fortran/56284] " arjen.markus at deltares dot nl
` (10 more replies)
0 siblings, 11 replies; 12+ messages in thread
From: arjen.markus at deltares dot nl @ 2013-02-11 8:58 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56284
Bug #: 56284
Summary: ICE with contained routine which inappropriately
compares a string and a number
Classification: Unclassified
Product: gcc
Version: 4.7.2
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: fortran
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: arjen.markus@deltares.nl
Created attachment 29414
--> http://gcc.gnu.org/bugzilla/attachment.cgi?id=29414
Code that causes the compiler to fail
The attached code causes an ICE in gfortran 4.7.2 (and 4.7.1) on Windows 7.
The fact that the routine is contained in a derived type is essential for the
occurrence of the ICE.
On my system there is just the message that an ICE occurred, if I comment out
the lines "contains" and "procedure :: getRecord", then the compiler rightly
complains about the mistake in the getRecord routine.
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug fortran/56284] ICE with contained routine which inappropriately compares a string and a number
2013-02-11 8:58 [Bug fortran/56284] New: ICE with contained routine which inappropriately compares a string and a number arjen.markus at deltares dot nl
@ 2013-02-11 9:02 ` arjen.markus at deltares dot nl
2013-02-11 9:51 ` [Bug fortran/56284] [OOP] " janus at gcc dot gnu.org
` (9 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: arjen.markus at deltares dot nl @ 2013-02-11 9:02 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56284
--- Comment #1 from Arjen Markus <arjen.markus at deltares dot nl> 2013-02-11 09:01:29 UTC ---
Correcting the mistakes still causes an ICE
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug fortran/56284] [OOP] ICE with contained routine which inappropriately compares a string and a number
2013-02-11 8:58 [Bug fortran/56284] New: ICE with contained routine which inappropriately compares a string and a number arjen.markus at deltares dot nl
2013-02-11 9:02 ` [Bug fortran/56284] " arjen.markus at deltares dot nl
@ 2013-02-11 9:51 ` janus at gcc dot gnu.org
2013-02-11 10:09 ` [Bug fortran/56284] [OOP] ICE with alternate return in type-bound procedure janus at gcc dot gnu.org
` (8 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: janus at gcc dot gnu.org @ 2013-02-11 9:51 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56284
janus at gcc dot gnu.org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Last reconfirmed| |2013-02-11
CC| |janus at gcc dot gnu.org
Summary|ICE with contained routine |[OOP] ICE with contained
|which inappropriately |routine which
|compares a string and a |inappropriately compares a
|number |string and a number
Ever Confirmed|0 |1
--- Comment #2 from janus at gcc dot gnu.org 2013-02-11 09:51:39 UTC ---
Reduced test case:
module try_this
implicit none
type :: table_t
contains
procedure, nopass :: getRecord
end type
contains
subroutine getRecord ( * )
end subroutine
end module
ICEs with 4.6, 4.7 and trunk. Backtrace:
f951: internal compiler error: Segmentation fault
0xb0f2cd crash_signal
/home/jweil/gcc48/trunk/gcc/toplev.c:332
0x57d360 compare_type_rank
/home/jweil/gcc48/trunk/gcc/fortran/interface.c:522
0x57e327 check_dummy_characteristics
/home/jweil/gcc48/trunk/gcc/fortran/interface.c:1027
0x57f25d gfc_compare_interfaces(gfc_symbol*, gfc_symbol*, char const*, int,
int, char*, int, char const*, char const*)
/home/jweil/gcc48/trunk/gcc/fortran/interface.c:1424
0x5d7600 resolve_structure_cons
/home/jweil/gcc48/trunk/gcc/fortran/resolve.c:1221
0x5eb85f resolve_values
/home/jweil/gcc48/trunk/gcc/fortran/resolve.c:10461
0x611b53 do_traverse_symtree
/home/jweil/gcc48/trunk/gcc/fortran/symbol.c:3448
0x611c1f gfc_traverse_ns(gfc_namespace*, void (*)(gfc_symbol*))
/home/jweil/gcc48/trunk/gcc/fortran/symbol.c:3473
0x5f663c resolve_types
/home/jweil/gcc48/trunk/gcc/fortran/resolve.c:14913
0x5f69a0 gfc_resolve(gfc_namespace*)
/home/jweil/gcc48/trunk/gcc/fortran/resolve.c:14995
0x5ce423 gfc_parse_file()
/home/jweil/gcc48/trunk/gcc/fortran/parse.c:4608
0x61adcd gfc_be_parse_file
/home/jweil/gcc48/trunk/gcc/fortran/f95-lang.c:189
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug fortran/56284] [OOP] ICE with alternate return in type-bound procedure
2013-02-11 8:58 [Bug fortran/56284] New: ICE with contained routine which inappropriately compares a string and a number arjen.markus at deltares dot nl
2013-02-11 9:02 ` [Bug fortran/56284] " arjen.markus at deltares dot nl
2013-02-11 9:51 ` [Bug fortran/56284] [OOP] " janus at gcc dot gnu.org
@ 2013-02-11 10:09 ` janus at gcc dot gnu.org
2013-02-11 12:17 ` janus at gcc dot gnu.org
` (7 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: janus at gcc dot gnu.org @ 2013-02-11 10:09 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56284
janus at gcc dot gnu.org changed:
What |Removed |Added
----------------------------------------------------------------------------
Summary|[OOP] ICE with contained |[OOP] ICE with alternate
|routine which |return in type-bound
|inappropriately compares a |procedure
|string and a number |
--- Comment #3 from janus at gcc dot gnu.org 2013-02-11 10:09:39 UTC ---
(In reply to comment #2)
>
> subroutine getRecord ( * )
> end subroutine
Ok, I admit that I had to look up the asterisk thingy. It's called "alternate
return" and is a obsolescent feature since at least F95.
According to PR 40881, we should have a warning message for this, but it does
not seem to trigger for the test case here. Should be fixed I guess (just as
the ICE, although combining obsolescent features like alternate return with new
stuff such as type binding is surely not recommended).
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug fortran/56284] [OOP] ICE with alternate return in type-bound procedure
2013-02-11 8:58 [Bug fortran/56284] New: ICE with contained routine which inappropriately compares a string and a number arjen.markus at deltares dot nl
` (2 preceding siblings ...)
2013-02-11 10:09 ` [Bug fortran/56284] [OOP] ICE with alternate return in type-bound procedure janus at gcc dot gnu.org
@ 2013-02-11 12:17 ` janus at gcc dot gnu.org
2013-02-11 12:37 ` janus at gcc dot gnu.org
` (6 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: janus at gcc dot gnu.org @ 2013-02-11 12:17 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56284
janus at gcc dot gnu.org changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |ice-on-valid-code
--- Comment #4 from janus at gcc dot gnu.org 2013-02-11 12:17:34 UTC ---
The following fixes the ICE:
Index: gcc/fortran/interface.c
===================================================================
--- gcc/fortran/interface.c (revision 195915)
+++ gcc/fortran/interface.c (working copy)
@@ -1023,6 +1023,9 @@ static gfc_try
check_dummy_characteristics (gfc_symbol *s1, gfc_symbol *s2,
bool type_must_agree, char *errmsg, int err_len)
{
+ if (s1 == NULL || s2 == NULL)
+ return s1 == s2 ? SUCCESS : FAILURE;
+
/* Check type and rank. */
if (type_must_agree && !compare_type_rank (s2, s1))
{
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug fortran/56284] [OOP] ICE with alternate return in type-bound procedure
2013-02-11 8:58 [Bug fortran/56284] New: ICE with contained routine which inappropriately compares a string and a number arjen.markus at deltares dot nl
` (3 preceding siblings ...)
2013-02-11 12:17 ` janus at gcc dot gnu.org
@ 2013-02-11 12:37 ` janus at gcc dot gnu.org
2013-02-11 13:57 ` janus at gcc dot gnu.org
` (5 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: janus at gcc dot gnu.org @ 2013-02-11 12:37 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56284
janus at gcc dot gnu.org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |ASSIGNED
AssignedTo|unassigned at gcc dot |janus at gcc dot gnu.org
|gnu.org |
--- Comment #5 from janus at gcc dot gnu.org 2013-02-11 12:36:46 UTC ---
... and this adds a warning about the obsolescent alternate return argument
(with -std=f2003 or f2008):
Index: gcc/fortran/decl.c
===================================================================
--- gcc/fortran/decl.c (revision 195915)
+++ gcc/fortran/decl.c (working copy)
@@ -4487,7 +4487,15 @@ gfc_match_formal_arglist (gfc_symbol *progname, in
for (;;)
{
if (gfc_match_char ('*') == MATCH_YES)
- sym = NULL;
+ {
+ sym = NULL;
+ if (gfc_notify_std (GFC_STD_F95_OBS, "Alternate return argument "
+ "at %C") == FAILURE)
+ {
+ m = MATCH_ERROR;
+ goto cleanup;
+ }
+ }
else
{
m = gfc_match_name (name);
Also: Mine.
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug fortran/56284] [OOP] ICE with alternate return in type-bound procedure
2013-02-11 8:58 [Bug fortran/56284] New: ICE with contained routine which inappropriately compares a string and a number arjen.markus at deltares dot nl
` (4 preceding siblings ...)
2013-02-11 12:37 ` janus at gcc dot gnu.org
@ 2013-02-11 13:57 ` janus at gcc dot gnu.org
2013-02-11 19:06 ` dominiq at lps dot ens.fr
` (4 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: janus at gcc dot gnu.org @ 2013-02-11 13:57 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56284
--- Comment #6 from janus at gcc dot gnu.org 2013-02-11 13:57:36 UTC ---
The combined patches of comment 4 and 5 yield the following testsuite failures:
FAIL: gfortran.dg/altreturn_2.f90 -O (test for excess errors)
FAIL: gfortran.dg/intrinsic_actual_3.f90 -O (test for excess errors)
FAIL: gfortran.dg/invalid_interface_assignment.f90 -O (test for excess
errors)
(all of them are clearly due to comment 5)
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug fortran/56284] [OOP] ICE with alternate return in type-bound procedure
2013-02-11 8:58 [Bug fortran/56284] New: ICE with contained routine which inappropriately compares a string and a number arjen.markus at deltares dot nl
` (5 preceding siblings ...)
2013-02-11 13:57 ` janus at gcc dot gnu.org
@ 2013-02-11 19:06 ` dominiq at lps dot ens.fr
2013-02-11 19:46 ` janus at gcc dot gnu.org
` (3 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: dominiq at lps dot ens.fr @ 2013-02-11 19:06 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56284
--- Comment #7 from Dominique d'Humieres <dominiq at lps dot ens.fr> 2013-02-11 19:06:10 UTC ---
> The combined patches of comment 4 and 5 yield the following testsuite failures:
>
> FAIL: gfortran.dg/altreturn_2.f90 -O (test for excess errors)
> FAIL: gfortran.dg/intrinsic_actual_3.f90 -O (test for excess errors)
> FAIL: gfortran.dg/invalid_interface_assignment.f90 -O (test for excess
> errors)
These tests are complied with -pedantic-errors and after the patch in comment
#5,
their compilation gives the corresponding warning:
Warning: Obsolescent feature: Alternate return argument at (1)
The tests pass with the following patch
--- /opt/gcc/_clean/gcc/testsuite/gfortran.dg/invalid_interface_assignment.f90
2010-02-10 17:54:15.000000000 +0100
+++ /opt/gcc/work/gcc/testsuite/gfortran.dg/invalid_interface_assignment.f90
2013-02-11 19:57:39.000000000 +0100
@@ -12,8 +12,9 @@ MODULE TT
MODULE PROCEDURE set
END INTERFACE
CONTAINS
- PURE SUBROUTINE set(x1,*) ! { dg-error "Alternate return cannot appear" }
+ PURE SUBROUTINE set(x1,*) ! { dg-warning "Obsolescent feature: Alternate
return argument" }
TYPE(data_type), INTENT(OUT) :: x1
x1%i=0
END SUBROUTINE set
END MODULE
+! { dg-error "Alternate return cannot appear" "" { target *-*-* } 15 }
--- /opt/gcc/_clean/gcc/testsuite/gfortran.dg/intrinsic_actual_3.f90
2009-11-25 18:17:42.000000000 +0100
+++ /opt/gcc/work/gcc/testsuite/gfortran.dg/intrinsic_actual_3.f90
2013-02-11 19:50:13.000000000 +0100
@@ -6,7 +6,7 @@
!
program ar1
interface random_seed
- subroutine x (a, *)
+ subroutine x (a, *) ! { dg-warning "Obsolescent feature: Alternate
return argument" }
integer a
end subroutine x
end interface random_seed
--- /opt/gcc/_clean/gcc/testsuite/gfortran.dg/altreturn_2.f90 2009-11-25
18:17:47.000000000 +0100
+++ /opt/gcc/work/gcc/testsuite/gfortran.dg/altreturn_2.f90 2013-02-11
19:48:14.000000000 +0100
@@ -2,7 +2,7 @@
program altreturn_2
call foo() ! { dg-error "Missing alternate return" }
contains
- subroutine foo(*)
+ subroutine foo(*) ! { dg-warning "Obsolescent feature: Alternate
return argument" }
return
end subroutine
end program
I don't know if it is the RIGHT fix, but at least it works (tested with
make -k check-gfortran RUNTESTFLAGS="dg.exp=invalid_interface_assignment.f90
--target_board=unix'{-m32,-m64}'"
and so on for the other two cases.
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug fortran/56284] [OOP] ICE with alternate return in type-bound procedure
2013-02-11 8:58 [Bug fortran/56284] New: ICE with contained routine which inappropriately compares a string and a number arjen.markus at deltares dot nl
` (6 preceding siblings ...)
2013-02-11 19:06 ` dominiq at lps dot ens.fr
@ 2013-02-11 19:46 ` janus at gcc dot gnu.org
2013-02-12 12:58 ` dominiq at lps dot ens.fr
` (2 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: janus at gcc dot gnu.org @ 2013-02-11 19:46 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56284
--- Comment #8 from janus at gcc dot gnu.org 2013-02-11 19:46:15 UTC ---
(In reply to comment #7)
> I don't know if it is the RIGHT fix, but at least it works (tested with
Yes, that's fine. Or one could just disable the errors with
! { dg-options "-std=legacy" }
in all three cases. Thought I had posted that already ...
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug fortran/56284] [OOP] ICE with alternate return in type-bound procedure
2013-02-11 8:58 [Bug fortran/56284] New: ICE with contained routine which inappropriately compares a string and a number arjen.markus at deltares dot nl
` (7 preceding siblings ...)
2013-02-11 19:46 ` janus at gcc dot gnu.org
@ 2013-02-12 12:58 ` dominiq at lps dot ens.fr
2013-02-12 13:31 ` janus at gcc dot gnu.org
2013-04-03 7:51 ` janus at gcc dot gnu.org
10 siblings, 0 replies; 12+ messages in thread
From: dominiq at lps dot ens.fr @ 2013-02-12 12:58 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56284
--- Comment #9 from Dominique d'Humieres <dominiq at lps dot ens.fr> 2013-02-12 12:57:55 UTC ---
Do you understand why the test in gfc_match_return (file match.c)
if (gfc_notify_std (GFC_STD_F95_OBS, "Alternate RETURN "
"at %C") == FAILURE)
return MATCH_ERROR;
is not used?
Note that the error is slightly different to the one used in comment #5.
Otherwise the patches fix this PR without regression. Thanks.
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug fortran/56284] [OOP] ICE with alternate return in type-bound procedure
2013-02-11 8:58 [Bug fortran/56284] New: ICE with contained routine which inappropriately compares a string and a number arjen.markus at deltares dot nl
` (8 preceding siblings ...)
2013-02-12 12:58 ` dominiq at lps dot ens.fr
@ 2013-02-12 13:31 ` janus at gcc dot gnu.org
2013-04-03 7:51 ` janus at gcc dot gnu.org
10 siblings, 0 replies; 12+ messages in thread
From: janus at gcc dot gnu.org @ 2013-02-12 13:31 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56284
--- Comment #10 from janus at gcc dot gnu.org 2013-02-12 13:31:22 UTC ---
(In reply to comment #9)
> Do you understand why the test in gfc_match_return (file match.c)
>
> if (gfc_notify_std (GFC_STD_F95_OBS, "Alternate RETURN "
> "at %C") == FAILURE)
> return MATCH_ERROR;
>
> is not used?
Yeah. The reason is that this one only triggers on an actual RETURN statement,
but not if an unused alt-return argument is declared (as e.g. in comment 2).
> Note that the error is slightly different to the one used in comment #5.
Yes, I did that on purpose, since both warn for slightly different things: The
former for an ('alternate') RETURN statement and the latter for an
alternate-return dummy argument.
In fact one could think about removing the error message in gfc_match_return
and only keeping the one in gfc_match_formal_arglist. After all it makes no
sense to have an alternate RETURN statement without an alternate-return dummy.
However, since gfortran only gives a warning for this case(*), I think it does
not hurt to keep both error messages.
(*) "Warning: An alternate return at (1) without a * dummy argument"
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug fortran/56284] [OOP] ICE with alternate return in type-bound procedure
2013-02-11 8:58 [Bug fortran/56284] New: ICE with contained routine which inappropriately compares a string and a number arjen.markus at deltares dot nl
` (9 preceding siblings ...)
2013-02-12 13:31 ` janus at gcc dot gnu.org
@ 2013-04-03 7:51 ` janus at gcc dot gnu.org
10 siblings, 0 replies; 12+ messages in thread
From: janus at gcc dot gnu.org @ 2013-04-03 7:51 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56284
janus at gcc dot gnu.org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution| |FIXED
--- Comment #11 from janus at gcc dot gnu.org 2013-04-03 07:51:18 UTC ---
Fixed with this commit:
http://gcc.gnu.org/viewcvs/gcc?view=revision&revision=197389
2013-04-03 Janus Weil <janus@gcc.gnu.org>
PR fortran/56284
PR fortran/40881
* decl.c (gfc_match_formal_arglist): Warn about alternate-return
arguments.
* interface.c (check_dummy_characteristics): Return if symbols are NULL.
2013-04-03 Janus Weil <janus@gcc.gnu.org>
PR fortran/56284
PR fortran/40881
* gfortran.dg/altreturn_8.f90: New.
* gfortran.dg/altreturn_2.f90: Add -std=legacy.
* gfortran.dg/intrinsic_actual_3.f90: Ditto.
* gfortran.dg/invalid_interface_assignment.f90: Ditto.
Closing.
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2013-04-03 7:51 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-02-11 8:58 [Bug fortran/56284] New: ICE with contained routine which inappropriately compares a string and a number arjen.markus at deltares dot nl
2013-02-11 9:02 ` [Bug fortran/56284] " arjen.markus at deltares dot nl
2013-02-11 9:51 ` [Bug fortran/56284] [OOP] " janus at gcc dot gnu.org
2013-02-11 10:09 ` [Bug fortran/56284] [OOP] ICE with alternate return in type-bound procedure janus at gcc dot gnu.org
2013-02-11 12:17 ` janus at gcc dot gnu.org
2013-02-11 12:37 ` janus at gcc dot gnu.org
2013-02-11 13:57 ` janus at gcc dot gnu.org
2013-02-11 19:06 ` dominiq at lps dot ens.fr
2013-02-11 19:46 ` janus at gcc dot gnu.org
2013-02-12 12:58 ` dominiq at lps dot ens.fr
2013-02-12 13:31 ` janus at gcc dot gnu.org
2013-04-03 7:51 ` janus at gcc dot gnu.org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).