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

            Bug ID: 105503
           Summary: vptr and data are uninitialised error for intent(out)
                    argument of abstract type
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: mscfd at gmx dot net
  Target Milestone: ---

Created attachment 52932
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=52932&action=edit
uninit_vptr

The attached module, compiled with

gfortran-12 -Wall uninit_vptr.f90 -c

gives

uninit_vptr.f90:34:19:

   34 |       call f%sub(x)
      |                   ^
Warning: ‘x._data’ is used uninitialized [-Wuninitialized]
uninit_vptr.f90:33:42:

   33 |       class(a), dimension(:), pointer :: x
      |                                          ^
note: ‘x’ declared here
uninit_vptr.f90:34:19:

   34 |       call f%sub(x)
      |                   ^
Warning: ‘x._vptr’ is used uninitialized [-Wuninitialized]
uninit_vptr.f90:33:42:

   33 |       class(a), dimension(:), pointer :: x
      |                                          ^
note: ‘x’ declared here

But argument x has the intent(out) attribute and the warning seems bogus. (The
original code, where this occured, is an implementation of the abstract factory
design pattern.)

Reply via email to