Bug 756466

Summary: gfortran functions with result() set cause problems with -finit-local-zero -fno-automatic in tandem
Product: [Fedora] Fedora Reporter: Karl <kaiserkarl31>
Component: gccAssignee: Jakub Jelinek <jakub>
Status: CLOSED UPSTREAM QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: low Docs Contact:
Priority: unspecified    
Version: 15CC: jakub
Target Milestone: ---   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2011-11-24 10:58:38 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:

Description Karl 2011-11-23 17:11:25 UTC
Description of problem:
If the compiler flags "-finit-local-zero" and "-fno-automatic" are both used, gfortran will spit out an error like this:
  Error: Function result 'h' at (1) cannot have an initializer
This does not happen if the function does not use the "result" attribute (that is, the result name is the same as the function name).

Version-Release number of selected component (if applicable):
GNU Fortran (GCC) 4.6.1 20110908 (Red Hat 4.6.1-9)

How reproducible:
Always

Steps to Reproduce:
1. Create the following file (call it hello.f90, for example):

program inittest
contains
   function hello (a) result (h)
      integer :: h
      h = 1
   end function hello
end program inittest

2. gfortran -finit-local-zero -fno-automatic hello.f90
 
Actual results:
Error: Function result 'h' at (1) cannot have an initializer

Expected results:
Compiles as usual.

Additional info:
If you change "h" to "hello" and omit the "result (h)" part, it works fine.

Comment 1 Jakub Jelinek 2011-11-24 10:58:38 UTC
Tracking this upstream.