Reported by Jakub. "gfortran -O2 -fwhole-file" generates a variadic call to
bar_. (The decl of the procedure itself is OK.)

Expected:
a) With -fwhole-file, the actual declaration should be used.
b) As Fortran does not support variadic calls at all, there should be never
variatic calls be generated.


(variadic calls are those whose prototype ends in C with "..."; when generating
the argument list with build_function_type_list the function is always
non-variadic (cf. also build_varargs_function_type_list) - if one generates the
argument list manually, the last argument should be VOID_TYPE.)

 * * *

subroutine bar (a, n)
  integer :: n, a(*)
end subroutine bar

subroutine foo (b, n)
  integer :: n, b(n)
  n = 6
  call bar (b, 5)
  b(1:5) = 0
end subroutine foo

 * * *

How to test (thanks to Jakub for the list of options):

a) x86_64 (for non floating points): Assembler has xorl %eax, %eax before the
call (i.e. the variadic function has no floating-point arguments)

b) In a debugger:  b var-tracking.c:8357 if insn->code == CALL_INSN
(which is if (INSN_P (insn)) in vt_initialize) -- and then:
debug_rtx (insn)


-- 
           Summary: Wrong call with variadic declaration
           Product: gcc
           Version: 4.6.0
            Status: UNCONFIRMED
          Keywords: wrong-code
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: burnus at gcc dot gnu dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44471

Reply via email to