https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111503
Bug ID: 111503 Summary: Issues with POINTER, OPTIONAL, CONTIGUOUS dummy arguments Product: gcc Version: 14.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: fortran Assignee: unassigned at gcc dot gnu.org Reporter: anlauf at gcc dot gnu.org Target Milestone: --- The following code shows an issue that popped up while looking at pr55978: program test implicit none integer, pointer, contiguous :: p(:) => null() print *, is_contiguous (p) call one (p) ! accepted call one () ! accepted (but see pr55978 comment#19) call one (null()) ! rejected, but accepted by NAG, Intel call one (null(p)) ! rejected by NAG, accepted by Intel contains subroutine one (x) integer, pointer, optional, contiguous, intent(in) :: x(:) ! integer, optional, contiguous, intent(in) :: x(:) ! accepted end subroutine one end Intel accepts the code as-is. NAG complains that NULL(p) is not contiguous: Error: pr11xxxx.f90, line 8: Argument X (no. 1) of ONE is a CONTIGUOUS pointer, but the actual argument NULL(P) is not simply contiguous I guess that NAG is correct here, and Intel does not properly diagnose. gfortran is maybe overly "cautious" and gives: pr11xxxx.f90:7:12: 7 | call one (null()) ! rejected, but accepted by NAG, Intel | 1 Error: Actual argument to contiguous pointer dummy 'x' at (1) must be simply contiguous pr11xxxx.f90:8:12: 8 | call one (null(p)) ! rejected by NAG, accepted by Intel | 1 Error: Actual argument to contiguous pointer dummy 'x' at (1) must be simply contiguous As - in the current context - null() is equivalent to an absent actual argument, I wonder whether we should relax our checks and follow NAG and Intel.