public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/59015] New: I/O of derived type with private component is forbidden
@ 2013-11-05 21:39 fxcoudert at gcc dot gnu.org
  2013-11-06  8:06 ` [Bug fortran/59015] I/O of PARAMETER " burnus at gcc dot gnu.org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: fxcoudert at gcc dot gnu.org @ 2013-11-05 21:39 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 59015
           Summary: I/O of derived type with private component is
                    forbidden
           Product: gcc
           Version: 4.9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: fxcoudert at gcc dot gnu.org

We should diagnose and prevent I/O of a derived-type object with one or more
private components. Example:

module foo
  type, public :: t
    private
    integer :: hidden
  end type t

  type(t), parameter, public :: v = t(42)
end module foo

program test
  use foo
  print *, v
end

This currently compiles and print 42. It should be rejected.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug fortran/59015] I/O of PARAMETER derived type with private component is forbidden
  2013-11-05 21:39 [Bug fortran/59015] New: I/O of derived type with private component is forbidden fxcoudert at gcc dot gnu.org
@ 2013-11-06  8:06 ` burnus at gcc dot gnu.org
  2013-11-06  9:45 ` fxcoudert at gcc dot gnu.org
  2013-11-06 10:10 ` fxcoudert at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: burnus at gcc dot gnu.org @ 2013-11-06  8:06 UTC (permalink / raw)
  To: gcc-bugs

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

Tobias Burnus <burnus at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |accepts-invalid, diagnostic
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2013-11-06
                 CC|                            |burnus at gcc dot gnu.org
            Summary|I/O of derived type with    |I/O of PARAMETER derived
                   |private component is        |type with private component
                   |forbidden                   |is forbidden
     Ever confirmed|0                           |1

--- Comment #1 from Tobias Burnus <burnus at gcc dot gnu.org> ---
Confirmed. Not even -pedantic -std=f95 has any effect.

Note: The issue only affects PARAMETER. For module variables, one gets:
  Error: Data transfer element at (1) cannot have PRIVATE components


Fortran 2008, "9.6.3 Data transfer input/output list", second bullet point of
paragraph 7 [see last sentence after the ";"]

"If a list item of derived type in an unformatted input/output statement is not
processed by a defined input/output procedure (9.6.4.8), and if any subobject
of that list item would be processed by a defined input/output procedure, the
list item is treated as if all of the components of the object were specified
in the list in component order (4.5.4.7); those components shall be accessible
in the scoping unit containing the input/output statement and shall not be
pointers or allocatable."


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug fortran/59015] I/O of PARAMETER derived type with private component is forbidden
  2013-11-05 21:39 [Bug fortran/59015] New: I/O of derived type with private component is forbidden fxcoudert at gcc dot gnu.org
  2013-11-06  8:06 ` [Bug fortran/59015] I/O of PARAMETER " burnus at gcc dot gnu.org
@ 2013-11-06  9:45 ` fxcoudert at gcc dot gnu.org
  2013-11-06 10:10 ` fxcoudert at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: fxcoudert at gcc dot gnu.org @ 2013-11-06  9:45 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Francois-Xavier Coudert <fxcoudert at gcc dot gnu.org> ---
We don't trigger the check in resolve.c:resolve_transfer() because we bail out
early:

  if (exp == NULL || (exp->expr_type != EXPR_VARIABLE
                      && exp->expr_type != EXPR_FUNCTION))
    return;

I'm testing a patch to allow EXPR_STRUCTURE to go through the checks.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug fortran/59015] I/O of PARAMETER derived type with private component is forbidden
  2013-11-05 21:39 [Bug fortran/59015] New: I/O of derived type with private component is forbidden fxcoudert at gcc dot gnu.org
  2013-11-06  8:06 ` [Bug fortran/59015] I/O of PARAMETER " burnus at gcc dot gnu.org
  2013-11-06  9:45 ` fxcoudert at gcc dot gnu.org
@ 2013-11-06 10:10 ` fxcoudert at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: fxcoudert at gcc dot gnu.org @ 2013-11-06 10:10 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Francois-Xavier Coudert <fxcoudert at gcc dot gnu.org> ---
Allowing EXPR_STRUCTURE to go through the tests (by adding it along
EXPR_VARIABLE and EXPR_FUNCTION) leads to a failure of c_ptr_tests_16.f90 (the
rest of the testsuite works ok). The code that triggers it uses a TRANSFER:

module foo
  type mytype
    integer, private :: a, b, c
  end type mytype
end module foo

  use foo
  type(mytype) x
  print *, transfer(32512, x)
end

There is a segfault when it tries to access the symbol of the TRANSFER:

  sym = exp->symtree->n.sym;

I'm not able to dig any further, so I'll let someone else take care of it.


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2013-11-06 10:10 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-11-05 21:39 [Bug fortran/59015] New: I/O of derived type with private component is forbidden fxcoudert at gcc dot gnu.org
2013-11-06  8:06 ` [Bug fortran/59015] I/O of PARAMETER " burnus at gcc dot gnu.org
2013-11-06  9:45 ` fxcoudert at gcc dot gnu.org
2013-11-06 10:10 ` fxcoudert at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).