public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "burnus at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug fortran/46991] New: [OOP] polymorphic assumed-size actual arguments
Date: Fri, 17 Dec 2010 10:41:00 -0000	[thread overview]
Message-ID: <bug-46991-4@http.gcc.gnu.org/bugzilla/> (raw)

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

           Summary: [OOP] polymorphic assumed-size actual arguments
           Product: gcc
           Version: 4.6.0
            Status: UNCONFIRMED
          Keywords: rejects-valid
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: burnus@gcc.gnu.org
                CC: janus@gcc.gnu.org


Found at http://j3-fortran.org/pipermail/j3/2010-December/004084.html

Currently, it is unclear whether the following program is valid, but Robert
Corbett of Oracle (formerly Sun) thinks it is (but does not seem to like it.)

[100% guessing, 90% wrongly]: The main issue he sees is seemingly that SUB2
does not need to have an explicit interface - which only works if the $data of
a CLASS and a TYPE object start at the same offset of the passed pointer
address.

I think that part is OK in gfortran, but gfortran has other issues:


Gfortran rejects the program with:

        CALL SUB2(A, N)
                  1
Warning: Type mismatch in argument 'a' at (1); passed CLASS(rec) to TYPE(rec)

[That's PR 46990.] I also tried SELECT TYPE but with limited success.


Using
        CLASS(REC) A(*)
one gets:
        PRINT *, A(:N)%A
                   1
Error: Syntax error in argument list at (1)


 * * *

       MODULE TYPES
         PRIVATE
         PUBLIC REC, REC2

         TYPE REC
           INTEGER A
         END TYPE

         TYPE, EXTENDS(REC) :: REC2
           INTEGER B
         END TYPE
       END

       SUBROUTINE SUB1(A, N)
         USE TYPES
         CLASS(REC), INTENT(IN) :: A(*)

         CALL SUB2(A, N)
       END

       SUBROUTINE SUB2(A, N)
         USE TYPES
         TYPE(REC) A(*)

         PRINT *, A(:N)%A
       END

       PROGRAM MAIN
         USE TYPES
         CLASS(REC), ALLOCATABLE :: A(:)
         INTERFACE
           SUBROUTINE SUB1(A, N)
             USE TYPES
             CLASS(REC), INTENT(IN) :: A(*)
           END SUBROUTINE
         END INTERFACE

         A = [ (REC2(I, I+1), I = 1, 10) ]
         CALL SUB1(A, 10)
       END


             reply	other threads:[~2010-12-17 10:41 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-12-17 10:41 burnus at gcc dot gnu.org [this message]
2012-12-23 22:17 ` [Bug fortran/46991] " anlauf at gmx dot de
2012-12-23 22:33 ` burnus at gcc dot gnu.org
2013-12-19  8:29 ` dominiq at lps dot ens.fr
2021-05-08 11:13 ` cvs-commit at gcc dot gnu.org
2021-09-06 19:07 ` anlauf at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-46991-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).