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

            Bug ID: 127892
           Summary: valgrind error in gfc_simplify_expr(gfc_expr*, int)
                    (expr.cc:2531)
           Product: gcc
           Version: 17.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: dcb314 at hotmail dot com
  Target Milestone: ---

Created attachment 65840
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=65840&action=edit
f90 source code

For the attached F90 code with a recent gfortran, compiled
with valgrind, does this:

$ ~/gcc/results.20261009.valgrind/bin/gfortran -c -w
/home/dcb42/llvm/trunk/flang/test/Evaluate/fold-transfer-partial.f90
==10592== Invalid read of size 2
==10592==    at 0x48501B0: memmove (vg_replace_strmem.c:1429)
==10592==    by 0x4D478B: gfc_simplify_expr(gfc_expr*, int) (expr.cc:2531)
==10592==    by 0x4D40EB: gfc_simplify_expr(gfc_expr*, int) (expr.cc:2488)
==10592==    by 0x4F573C: gfc_intrinsic_func_interface(gfc_expr*, int)
(intrinsic.cc:5483)

The code is from the flang testsuite, part of llvm on github.

The bug seems to first occur sometime before 20261003.
The relevant lines of code are

      s = gfc_get_wide_string (end - start + 2);
      memcpy (s, p->value.character.string + start,
          (end - start) * sizeof (gfc_char_t));
      s[end - start + 1] = '\0';  /* TODO: C-style string.  */

Reply via email to