[Bug fortran/33106] New: Access of components of public entities of private types wrongly allowed

burnus at gcc dot gnu dot org gcc-bugzilla@gcc.gnu.org
Sat Aug 18 12:01:00 GMT 2007


Example found in the NAG f95 release notes.

The "print" statements are wrong(?); additionally for -std=f95 there should be
already an error for the compilation of the module.

NAG f95 prints:

Error: b.f90, line 14: Derived type HIDDEN_TYPE in io-list has PRIVATE
components
Interestingly, line 15 is accepted (omission or valid?).

With -std=f95, NAG f95 prints:

Error: b.f90, line 9: PARAMETER CODE_YELLOW exposes PRIVATE type HIDDEN_TYPE
           detected at M@<end-of-statement>
[...]
Which is in line with ifort:
fortcom: Error: b.f90, line 6: This entity cannot be PUBLIC since its derived
type is PRIVATE.   [CODE_GREEN]
  type(hidden_type), public, parameter :: code_green = hidden_type('green')


module m
  implicit none
  type, private :: hidden_type
    character(6) :: code
  end type
  type(hidden_type), public, parameter :: code_green = hidden_type('green')
  type(hidden_type), public, parameter :: code_yellow = hidden_type('yellow')
  type(hidden_type), public, parameter :: code_red = hidden_type('red')
end module m

program test
  use m, only: code_yellow
  implicit none
  print *, code_yellow
  print *, code_yellow%code
end program test


-- 
           Summary: Access of components of public entities of private types
                    wrongly allowed
           Product: gcc
           Version: 4.3.0
            Status: UNCONFIRMED
          Keywords: accepts-invalid
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: burnus at gcc dot gnu dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33106



More information about the Gcc-bugs mailing list