This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug libfortran/81984] New: NULL string pointer dereferencing forces undefined behaviour in libgfortran
- From: "zeccav at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Fri, 25 Aug 2017 13:44:37 +0000
- Subject: [Bug libfortran/81984] New: NULL string pointer dereferencing forces undefined behaviour in libgfortran
- Auto-submitted: auto-generated
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 <burnus@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