Bug 33550 - ICE (segfault) when USEing ambiguous symbols
Summary: ICE (segfault) when USEing ambiguous symbols
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 4.3.0
: P3 normal
Target Milestone: ---
Assignee: Paul Thomas
URL:
Keywords: ice-on-invalid-code
Depends on:
Blocks:
 
Reported: 2007-09-25 06:20 UTC by Tobias Burnus
Modified: 2007-10-02 08:45 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2007-09-30 16:55:35


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Tobias Burnus 2007-09-25 06:20:12 UTC
Found at http://groups.google.com/group/comp.lang.fortran/browse_thread/thread/1abc1549a6a164f1/
by James Van Buskirk:
-------------------------
module M1
   real x
end module M1

module M2
   contains
      subroutine y
      end subroutine y
end module M2

module M3
   use M2, x => y
end module M3

module M4
   use M1
   use M3
end module M4

module M5
   use M4
end module M5

module M6
   use M5
end module M6

program test
   use M6
   interface
      function x(z)
      end function x
   end interface

   write(*,*) 'Hello, world!'
end program test

function x(z)
   x = z
end function x
-------------------------

g95:
In file a.f90:31
      function x(z)
                1
Error: Name 'x' at (1) is an ambiguous reference to 'x' from module 'm1'

NAG f95:
Error: a.f90, line 31: Symbol X resolves to X in module M1 and to Y in module M2
       detected at FUNCTION@X
Error: a.f90, line 31: Redeclaration of symbol Y from USEd module
       detected at FUNCTION@X
Error: a.f90, line 31: Duplicate subprogram name Y
       detected at FUNCTION@X

valgrind:
==7549== Conditional jump or move depends on uninitialised value(s)
==7549==    at 0x416222: get_proc_name (decl.c:712)
==7549==    by 0x4186DA: gfc_match_function_decl (decl.c:4054)
==7549==    by 0x44EE4F: decode_statement (parse.c:116)
==7549==    by 0x44FAE4: next_statement (parse.c:505)
==7549==    by 0x451023: parse_spec (parse.c:1747)
==7549==    by 0x4527B5: parse_progunit (parse.c:2965)
==7549==    by 0x452C79: gfc_parse_file (parse.c:3271)
==7549==    by 0x479C24: gfc_be_parse_file (f95-lang.c:258)
==7549==    by 0x6D4B61: toplev_main (toplev.c:1039)
Comment 1 Paul Thomas 2007-09-30 16:55:35 UTC
Since I posted a fix, I had better take it!

Paul
Comment 2 Paul Thomas 2007-10-02 07:53:16 UTC
Subject: Bug 33550

Author: pault
Date: Tue Oct  2 07:53:05 2007
New Revision: 128949

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=128949
Log:
2007-10-02  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/33550
	* decl.c (get_proc_name): Return rc if rc is non-zero; ie. if
	the name is a reference to an ambiguous symbol.

2007-10-02  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/33550
	* gfortran.dg/ambiguous_reference_1.f90: New test.

Added:
    trunk/gcc/testsuite/gfortran.dg/ambiguous_reference_1.f90
Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/decl.c
    trunk/gcc/testsuite/ChangeLog

Comment 3 Paul Thomas 2007-10-02 08:45:16 UTC
Fixed on trunk

Paul