PROGRAM TSBVSL CALL NRANIN(54321.) END SUBROUTINE NRAN(VECTOR,N) DIMENSION VECTOR(N) DO I=1,N VECTOR(I) = RNDM(I) END DO RETURN ENTRY NRANIN (V) CALL RDMIN(V) RETURN END
SUBROUTINE RDMIN(V) END REAL FUNCTION RNDM(I) RNDM=I END is miscompiled on x86_64-linux at -O and higher. The problem is that gfc_trans_deferred_vars emits some code e.g. to compute array argument's ubound and this happens before the entry master switch, so the the N argument pointer might be NULL. I think we should: a) in gfc_sym_type try harder for !sym->attr.optional && sym->ns->proc_name->attr.entry_master to see whether build_reference_type (type) could be used by walking all entries and see if the argument is present in all the entries and not optional, then it can be reference_type b) probably use some flag set for all code emitted before the entry master switch which would cause all parameters to expand to p != NULL ? *p : 0 rather than just *p if p is POINTER_TYPE. -- Summary: Problem with handling optional and entry master arguments Product: gcc Version: 4.1.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: fortran AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: jakub at gcc dot gnu dot org http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25818