https://gcc.gnu.org/bugzilla/show_bug.cgi?id=126018

            Bug ID: 126018
           Summary: gfortran rejects character function invocation as stop
                    code
           Product: gcc
           Version: 16.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: damian at archaeologic dot codes
  Target Milestone: ---

The following code is accepted by the NAG and LLVM flang compilers:

% cat character-function-stop-code.f90 
  implicit none
  error stop character_stop_code()
contains
  character(1) function character_stop_code()
    character_stop_code = "a"
  end function
end 

% gfortran character-function-stop-code.f90 
character-function-stop-code.f90:2:13:

    2 |   error stop character_stop_code()
      |             1
Error: STOP code at (1) must be either INTEGER or CHARACTER type

% gfortran --version
GNU Fortran (Homebrew GCC 16.1.0) 16.1.0

gfortran 13.4.0, 14.3.0, and 15.3.0 all give the same error message. It would
be great if a fix could be back-ported at least to the 15 branch.

Reply via email to