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

            Bug ID: 96886
           Summary: valgrind error with optional character argument of
                    unknown length
           Product: gcc
           Version: 10.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libfortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: ajmay81 at googlemail dot com
  Target Milestone: ---

Looks like a regression between 10.1.0 and 10.2.0. test.f90:

module test_module
  implicit none
contains
  subroutine testsub0(propnam)
    character(*), intent(in), optional :: propnam(*)
    if(.not.present(propnam)) then
       stop 'property names not given'
    else
       write(*,*) propnam(1)
    endif
  end subroutine testsub0
end module test_module

program bug
  use test_module
  implicit none
  character(8) :: prop(1)
  prop(1)='POT'
  call testsub0(propnam=prop)
end program bug

bug> module load gcc/10.2.0
bug> gfortran test.f90 && valgrind ./a.out
==31524== Memcheck, a memory error detector
==31524== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==31524== Using Valgrind-3.15.0 and LibVEX; rerun with -h for copyright info
==31524== Command: ./a.out
==31524==
==31524== Conditional jump or move depends on uninitialised value(s)
==31524==    at 0x400741: __test_module_MOD_testsub0 (in /home/andy/bug/a.out)
==31524==    by 0x400825: MAIN__ (in /home/andy/bug/a.out)
==31524==    by 0x40085C: main (in /home/andy/bug/a.out)
==31524== 
==31524== Conditional jump or move depends on uninitialised value(s)
==31524==    at 0x400762: __test_module_MOD_testsub0 (in /home/andy/bug/a.out)
==31524==    by 0x400825: MAIN__ (in /home/andy/bug/a.out)
==31524==    by 0x40085C: main (in /home/andy/bug/a.out)
==31524== 
STOP property names not given
==31524== 
==31524== HEAP SUMMARY:
==31524==     in use at exit: 0 bytes in 0 blocks
==31524==   total heap usage: 21 allocs, 21 frees, 13,584 bytes allocated
==31524==
==31524== All heap blocks were freed -- no leaks are possible
==31524== 
==31524== Use --track-origins=yes to see where uninitialised values come from
==31524== For lists of detected and suppressed errors, rerun with: -s
==31524== ERROR SUMMARY: 2 errors from 2 contexts (suppressed: 0 from 0)

bug> module purge
bug> module load gcc/10.1.0 
bug> gfortran test.f90 && valgrind ./a.out
==31516== Memcheck, a memory error detector
==31516== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==31516== Using Valgrind-3.15.0 and LibVEX; rerun with -h for copyright info
==31516== Command: ./a.out
==31516== 
 POT     
==31516== 
==31516== HEAP SUMMARY:
==31516==     in use at exit: 0 bytes in 0 blocks
==31516==   total heap usage: 21 allocs, 21 frees, 13,584 bytes allocated
==31516== 
==31516== All heap blocks were freed -- no leaks are possible
==31516== 
==31516== For lists of detected and suppressed errors, rerun with: -s
==31516== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)

Reply via email to