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

            Bug ID: 81984
           Summary: NULL string pointer dereferencing forces undefined
                    behaviour in libgfortran
           Product: gcc
           Version: 8.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libfortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: zeccav at gmail dot com
  Target Milestone: ---
              Host: x86_64-pc-linux-gnu
             Build: trunk 251201

! From test case allocate_deferred_char_scalar_1.f03
! Contributed by Tobias Burnus  <bur...@gcc.gnu.org>
! Must be compiled and run with sanitized libgfortran
! NULL string pointer dereferencing forces undefined behaviour in libgfortran 
! libgfortran/intrinsics/string_intrinsics_inc.c:90:7: runtime error: null
pointer passed as argument 1, which is declared to never be null
! string_intrinsics_inc.c:90 is "res = MEMCMP (s1, s2, ((len1 < len2) ? len1 :
len2));"
! len1 is probably zero so the operation is undefined but harmless
! A fix could be "res = len1==0 ? 0 : MEMCMP (s1, s2, ((len1 < len2) ? len1 :
len2));"
      character(len=:), pointer :: str4
      logical l
      nullify(str4)
      l= str4=='12a56b78'
      end

Reply via email to