Bug 24223 - Gfortran crashes in two places
Summary: Gfortran crashes in two places
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 4.1.0
: P2 normal
Target Milestone: 4.0.3
Assignee: Not yet assigned to anyone
URL:
Keywords: ice-on-valid-code
Depends on:
Blocks: Fortran_character 20405
  Show dependency treegraph
 
Reported: 2005-10-06 01:54 UTC by Van Snyder
Modified: 2005-12-12 20:11 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2005-10-06 03:24:12


Attachments
Source code that causes crash (37.76 KB, application/octet-stream)
2005-10-06 01:59 UTC, Van Snyder
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Van Snyder 2005-10-06 01:54:23 UTC
flags.f90:0: internal compiler error: backend decl for module variable at already exists
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://gcc.gnu.org/bugs.html> for instructions.

literals_m.f90:0: internal compiler error: Segmentation fault
Please submit a full bug report,
with preprocessed source if appropriate.

How do I attach source causing error?

GNU Fortran 95 (GCC) 4.1.0 20051005 (experimental)
Copyright (C) 2005 Free Software Foundation, Inc.

Downloaded binary for x86/Linux -- didn't compile gfortran myself.
Comment 1 Van Snyder 2005-10-06 01:59:03 UTC
Created attachment 9899 [details]
Source code that causes crash

I tried to compile this program using the Makefile in the tarball.  It got an internal error "backend decl for module variable at already exists" in flags.f90 and "Segmentation fault" in lexer_m.f90.
Comment 2 Andrew Pinski 2005-10-06 02:42:44 UTC
I am going to reduce both of these, I can reproduce them, I just will make this a meta-bug and make new bugs for the reduced testcases.
Comment 3 Andrew Pinski 2005-10-06 03:14:18 UTC
Oh, the second ICE is because of the first one.
Comment 4 Andrew Pinski 2005-10-06 03:24:12 UTC
Reduced testcase:

module FLAGS
  character(len=5) :: Encodings
  character :: at, dev
  equivalence ( encodings(1:1),at ), ( encodings(2:2),dev)
end module FLAGS
----

Like PR 17917 but this time with character/string.
Comment 5 Paul Thomas 2005-11-10 14:46:10 UTC
A give-away here is that inverting the order of the equivalence members, makes the problem go away.  The path below cures the problem but I have not regtested yet.....

Paul T

Index: gcc/gcc/fortran/trans-decl.c
===================================================================
RCS file: /cvsroot/gcc/gcc/gcc/fortran/trans-decl.c,v
retrieving revision 1.73
diff -c -p -r1.73 trans-decl.c
*** gcc/gcc/fortran/trans-decl.c        25 Oct 2005 14:06:22 -0000      1.
--- gcc/gcc/fortran/trans-decl.c        10 Nov 2005 14:43:51 -0000
*************** gfc_create_module_variable (gfc_symbol *
*** 2297,2303 ****
      return;

    /* Equivalenced variables arrive here after creation.  */
!   if (sym->backend_decl && sym->equiv_built)
        return;

    if (sym->backend_decl)
--- 2297,2303 ----
      return;

    /* Equivalenced variables arrive here after creation.  */
!   if (sym->backend_decl && (sym->equiv_built || sym->attr.in_equivalence
        return;

    if (sym->backend_decl)
Comment 6 Paul Thomas 2005-11-21 16:06:03 UTC
Subject: Bug 24223

Author: pault
Date: Mon Nov 21 16:05:58 2005
New Revision: 107310

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=107310
Log:
2005-11-21  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/24223
	* resolve.c (resolve_contained_fntype) Error if an internal
	function is assumed character length.

	PR fortran/24705
	* trans-decl.c (gfc_create_module_variable) Skip ICE in
	when backend decl has been built and the symbol is marked
	as being in an equivalence statement.

2005-11-21  Paul Thomas  <pault@gcc.gnu.org

	PR fortran/24223
	* gfortran.dg/substring_equivalence.f90: New test.

	PR fortran/24705
	* gfortran.dg/auto_internal_assumed.f90: New test.

Added:
    trunk/gcc/testsuite/gfortran.dg/auto_internal_assumed.f90   (with props)
    trunk/gcc/testsuite/gfortran.dg/substring_equivalence.f90   (with props)
Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/resolve.c
    trunk/gcc/fortran/trans-decl.c
    trunk/gcc/testsuite/ChangeLog

Added: trunk/gcc/testsuite/gfortran.dg/auto_internal_assumed.f90
URL: http://gcc.gnu.org/viewcvs/trunk/gcc/testsuite/gfortran.dg/auto_internal_assumed.f90?root=gcc&view=auto&rev=107310
==============================================================================
--- trunk/gcc/testsuite/gfortran.dg/auto_internal_assumed.f90 (added)
+++ trunk/gcc/testsuite/gfortran.dg/auto_internal_assumed.f90 Mon Nov 21 16:05:58 2005
@@ -1,0 +1,13 @@
+! { dg-do compile }
+! Test fix of PR24705 - ICE on assumed character length
+! internal function.
+!
+character (6) :: c
+  c = f1 ()        ! { dg-error "must not be assumed length" }
+  if (c .ne. 'abcdef') call abort
+contains
+  function f1 ()
+    character (*) :: f1
+    f1 = 'abcdef'
+  end function f1
+end

Propchange: trunk/gcc/testsuite/gfortran.dg/auto_internal_assumed.f90
            ('svn:executable' added)

Added: trunk/gcc/testsuite/gfortran.dg/substring_equivalence.f90
URL: http://gcc.gnu.org/viewcvs/trunk/gcc/testsuite/gfortran.dg/substring_equivalence.f90?root=gcc&view=auto&rev=107310
==============================================================================
--- trunk/gcc/testsuite/gfortran.dg/substring_equivalence.f90 (added)
+++ trunk/gcc/testsuite/gfortran.dg/substring_equivalence.f90 Mon Nov 21 16:05:58 2005
@@ -1,0 +1,8 @@
+! { dg-do compile }
+! Tests fix for PR24223 - ICE on equivalence staement.
+!
+module FLAGS
+  character(len=5) :: Encodings
+  character :: at, dev
+  equivalence ( encodings(1:1),at ), ( encodings(2:2),dev)
+end module FLAGS

Propchange: trunk/gcc/testsuite/gfortran.dg/substring_equivalence.f90
            ('svn:executable' added)


Comment 7 Paul Thomas 2005-11-21 20:03:00 UTC
Subject: Bug 24223

Author: pault
Date: Mon Nov 21 20:02:54 2005
New Revision: 107320

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=107320
Log:
2005-11-21  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/24223
	* resolve.c (resolve_contained_fntype) Error if an internal
	function is assumed character length.

	PR fortran/24705
	* trans-decl.c (gfc_create_module_variable) Skip ICE in
	when backend decl has been built and the symbol is marked
	as being in an equivalence statement.

2005-11-21  Paul Thomas  <pault@gcc.gnu.org

	PR fortran/24223
	* gfortran.dg/substring_equivalence.f90: New test.

	PR fortran/24705
	* gfortran.dg/auto_internal_assumed.f90: New test.

Added:
    branches/gcc-4_0-branch/gcc/testsuite/gfortran.dg/auto_internal_assumed.f90
    branches/gcc-4_0-branch/gcc/testsuite/gfortran.dg/substring_equivalence.f90
Modified:
    branches/gcc-4_0-branch/gcc/fortran/ChangeLog
    branches/gcc-4_0-branch/gcc/fortran/resolve.c
    branches/gcc-4_0-branch/gcc/fortran/trans-decl.c
    branches/gcc-4_0-branch/gcc/testsuite/ChangeLog

Comment 8 Paul Thomas 2005-11-30 19:26:28 UTC
Subject: Bug 24223

Author: pault
Date: Wed Nov 30 19:26:23 2005
New Revision: 107732

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=107732
Log:
2005-11-30  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/24223
	* resolve.c (resolve_contained_fntype) Error if an internal
	function is assumed character length.

	PR fortran/24705
	* trans-decl.c (gfc_create_module_variable) Skip ICE in
	when backend decl has been built and the symbol is marked
	as being in an equivalence statement.

2005-11-30  Paul Thomas  <pault@gcc.gnu.org

	PR fortran/24223
	* gfortran.dg/substring_equivalence.f90: New test.

	PR fortran/24705
	* gfortran.dg/auto_internal_assumed.f90: New test.

Added:
    branches/gcc-4_1-branch/gcc/testsuite/gfortran.dg/auto_internal_assumed.f90
    branches/gcc-4_1-branch/gcc/testsuite/gfortran.dg/substring_equivalence.f90
Modified:
    branches/gcc-4_1-branch/gcc/fortran/ChangeLog
    branches/gcc-4_1-branch/gcc/fortran/resolve.c
    branches/gcc-4_1-branch/gcc/fortran/trans-decl.c
    branches/gcc-4_1-branch/gcc/testsuite/ChangeLog

Comment 9 Paul Thomas 2005-11-30 19:35:27 UTC
Fixed in all 4.x