https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80467
Bug ID: 80467 Summary: Function Without Arguments Fails to Generate Error When Declared Later Product: gcc Version: 6.3.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: fortran Assignee: unassigned at gcc dot gnu.org Reporter: jeffrey.armstrong at approximatrix dot com Target Milestone: --- Calling a real-valued function without arguments and without providing an argument list will generate unexpected results if the function is declared after its call. Consider the following short example: !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! program noargs implicit none Print *, "Testing..." Call TestArgs Print *, "Done." contains Subroutine TestArgs implicit none Real::compareTo Integer::i compareTo = GetValue do i=1,10 if(compareTo < Real(i)) Then Print *, "bigger" end if end do End Subroutine TestArgs Function GetValue() implicit none Real::GetValue GetValue = 3.0 End Function GetValue end program noargs !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 6.3.0 will compile the above without any error messages, but the value of "compareTo" in the subroutine "TestArgs" will be a nonsense value. If the function GetValue is defined prior to TestArgs, the compiler correctly generates the error stating the GetValue requires an argument list. In a far more complex program, this same scenario was causing an ICE at gcc/expr.c:268. Either adding an empty argument list or rearranging the order of the function and calling subroutine fixed the issue. This bug was seen on MinGW-w64 and macOS (x64), but it should occur anywhere.