This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug fortran/81978] New: Passing component of a parameter array to a subroutine causes SIGBUS crash


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81978

            Bug ID: 81978
           Summary: Passing component of a parameter array to a subroutine
                    causes SIGBUS crash
           Product: gcc
           Version: 7.1.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: david.sagan at gmail dot com
  Target Milestone: ---

Consider the following program:

module test_mod
contains
subroutine match_word (names)
implicit none
character(*) names(:)
end subroutine
end module

program test
use test_mod
implicit none

type pp_struct
  character(40) name
  real value
end type

type (pp_struct), parameter :: pp(2) = [ &
                 pp_struct('pi', 3.1), &
                 pp_struct('twopi', 6.3)]

print *, 'In'
call match_word(pp%name)
print *, 'Out'
end program



Compiling and running produces:

Davids-Mac-mini:~/Downloads> gfortran test.f90; ./a.out 
 In

Program received signal SIGBUS: Access to an undefined portion of a memory
object.

Backtrace for this error:
#0  0x105ff50bc
#1  0x105ff48aa
#2  0x7fffb3bd6b39
#3  0x105fecd68
#4  0x105fece2e
Bus error: 10

Note: If "parameter" is not used with the pp array, the program runs fine.

Davids-Mac-mini:~/Downloads> gcc --version
gcc (MacPorts gcc7 7-20170622_1) 7.1.1 20170622

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]