public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "janus at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug fortran/59414] [OOP] Class array pointers: compile error on valid code (Different ranks in pointer assignment)
Date: Sat, 07 Dec 2013 11:56:00 -0000	[thread overview]
Message-ID: <bug-59414-4-Ui3vjmpwtJ@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-59414-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #2 from janus at gcc dot gnu.org ---
This draft patch fixes the error (but has not been regtested yet):

Index: gcc/fortran/resolve.c
===================================================================
--- gcc/fortran/resolve.c    (revision 205782)
+++ gcc/fortran/resolve.c    (working copy)
@@ -2616,6 +2616,8 @@ found:
     expr->ts = sym->ts;
   expr->value.function.name = sym->name;
   expr->value.function.esym = sym;
+  if (sym->ts.type == BT_CLASS && CLASS_DATA (sym)->as)
+    expr->rank = CLASS_DATA (sym)->as->rank;
   if (sym->as != NULL)
     expr->rank = sym->as->rank;


With the patch the reduced test case in comment 1 compiles cleanly, but the
full code in comment 0 then gives an ICE on a different location:

ObjectLists.f90: In function ‘addarray’:
ObjectLists.f90:240:0: internal compiler error: in gfc_conv_expr_descriptor, at
fortran/trans-array.c:6473
             allocate(Pt%P(1:SIZE(P)), source= P)
 ^
0x636b4b gfc_conv_expr_descriptor(gfc_se*, gfc_expr*)
    /home/jweil/gcc49/trunk/gcc/fortran/trans-array.c:6473
0x65597e gfc_trans_pointer_assignment(gfc_expr*, gfc_expr*)
    /home/jweil/gcc49/trunk/gcc/fortran/trans-expr.c:6609
0x676cd1 gfc_trans_allocate(gfc_code*)
    /home/jweil/gcc49/trunk/gcc/fortran/trans-stmt.c:5124
0x6269c7 trans_code
    /home/jweil/gcc49/trunk/gcc/fortran/trans.c:1778
0x66df53 gfc_trans_if_1
    /home/jweil/gcc49/trunk/gcc/fortran/trans-stmt.c:986
0x673d2a gfc_trans_if(gfc_code*)
    /home/jweil/gcc49/trunk/gcc/fortran/trans-stmt.c:1017
0x626aa7 trans_code
    /home/jweil/gcc49/trunk/gcc/fortran/trans.c:1720
0x674088 gfc_trans_block_construct(gfc_code*)
    /home/jweil/gcc49/trunk/gcc/fortran/trans-stmt.c:1344
0x626a37 trans_code
    /home/jweil/gcc49/trunk/gcc/fortran/trans.c:1728
0x66df53 gfc_trans_if_1
    /home/jweil/gcc49/trunk/gcc/fortran/trans-stmt.c:986
0x673d2a gfc_trans_if(gfc_code*)
    /home/jweil/gcc49/trunk/gcc/fortran/trans-stmt.c:1017
0x626aa7 trans_code
    /home/jweil/gcc49/trunk/gcc/fortran/trans.c:1720
0x67585d gfc_trans_integer_select
    /home/jweil/gcc49/trunk/gcc/fortran/trans-stmt.c:1992
0x67585d gfc_trans_select(gfc_code*)
    /home/jweil/gcc49/trunk/gcc/fortran/trans-stmt.c:2486
0x626a47 trans_code
    /home/jweil/gcc49/trunk/gcc/fortran/trans.c:1744
0x674088 gfc_trans_block_construct(gfc_code*)
    /home/jweil/gcc49/trunk/gcc/fortran/trans-stmt.c:1344
0x626a37 trans_code
    /home/jweil/gcc49/trunk/gcc/fortran/trans.c:1728
0x646382 gfc_generate_function_code(gfc_namespace*)
    /home/jweil/gcc49/trunk/gcc/fortran/trans-decl.c:5604
0x627ed1 gfc_generate_module_code(gfc_namespace*)
    /home/jweil/gcc49/trunk/gcc/fortran/trans.c:1956
0x5da09b translate_all_program_units
    /home/jweil/gcc49/trunk/gcc/fortran/parse.c:4523
>From gcc-bugs-return-436943-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Sat Dec 07 12:05:35 2013
Return-Path: <gcc-bugs-return-436943-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 2158 invoked by alias); 7 Dec 2013 12:05:35 -0000
Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm
Precedence: bulk
List-Id: <gcc-bugs.gcc.gnu.org>
List-Archive: <http://gcc.gnu.org/ml/gcc-bugs/>
List-Post: <mailto:gcc-bugs@gcc.gnu.org>
List-Help: <mailto:gcc-bugs-help@gcc.gnu.org>
Sender: gcc-bugs-owner@gcc.gnu.org
Delivered-To: mailing list gcc-bugs@gcc.gnu.org
Received: (qmail 2144 invoked by uid 48); 7 Dec 2013 12:05:30 -0000
From: "ville.voutilainen at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/59416] New: A nested template reusing the template arguments of the enclosing type in a template template argument not working
Date: Sat, 07 Dec 2013 12:05:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: new
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: c++
X-Bugzilla-Version: 4.9.0
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: ville.voutilainen at gmail dot com
X-Bugzilla-Status: UNCONFIRMED
X-Bugzilla-Priority: P3
X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org
X-Bugzilla-Target-Milestone: ---
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter
Message-ID: <bug-59416-4@http.gcc.gnu.org/bugzilla/>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/
Auto-Submitted: auto-generated
MIME-Version: 1.0
X-SW-Source: 2013-12/txt/msg00598.txt.bz2
Content-length: 1661

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

            Bug ID: 59416
           Summary: A nested template reusing the template arguments of
                    the enclosing type in a template template argument not
                    working
           Product: gcc
           Version: 4.9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: ville.voutilainen at gmail dot com

Test:

template<int,int> struct Obj; 
template<typename... Ts> struct A {
  template<template<Ts...> class> struct B { };
};

int main()
{ 
  A<int,int>::B<Obj> x{ }; 
} 

edoceo3.cpp:8:20: error: type/value mismatch at argument 1 in template
parameter list for ‘template<class ... Ts> template<template<template<Ts
...<anonymous> > class<template-parameter-2-1> > template<class ... Ts>
template<Ts ...<anonymous> > class<template-parameter-2-1> > struct A<Ts>::B’
   A<int,int>::B<Obj> x{ }; 
                    ^
edoceo3.cpp:8:20: error:   expected a template of type ‘template<class ... Ts>
template<Ts ...<anonymous> > class<template-parameter-2-1>’, got ‘template<int
<anonymous>, int <anonymous> > struct Obj’
edoceo3.cpp:8:23: error: invalid type in declaration before ‘{’ token
   A<int,int>::B<Obj> x{ }; 

clang compiles this code. It certainly looks valid to me, since in the
attempted instantiation, A's template arguments are 'int,int', and then
the template argument for A::B should be 'template <int, int> class',
and Obj is such a template.
>From gcc-bugs-return-436944-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Sat Dec 07 12:25:21 2013
Return-Path: <gcc-bugs-return-436944-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 14145 invoked by alias); 7 Dec 2013 12:25:21 -0000
Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm
Precedence: bulk
List-Id: <gcc-bugs.gcc.gnu.org>
List-Archive: <http://gcc.gnu.org/ml/gcc-bugs/>
List-Post: <mailto:gcc-bugs@gcc.gnu.org>
List-Help: <mailto:gcc-bugs-help@gcc.gnu.org>
Sender: gcc-bugs-owner@gcc.gnu.org
Delivered-To: mailing list gcc-bugs@gcc.gnu.org
Received: (qmail 14105 invoked by uid 48); 7 Dec 2013 12:25:17 -0000
From: "janus at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug fortran/59414] [OOP] Class array pointers: compile error on valid code (Different ranks in pointer assignment)
Date: Sat, 07 Dec 2013 12:25:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: fortran
X-Bugzilla-Version: 4.8.2
X-Bugzilla-Keywords: rejects-valid
X-Bugzilla-Severity: blocker
X-Bugzilla-Who: janus at gcc dot gnu.org
X-Bugzilla-Status: NEW
X-Bugzilla-Priority: P3
X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org
X-Bugzilla-Target-Milestone: ---
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields:
Message-ID: <bug-59414-4-kym0KJyvXt@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-59414-4@http.gcc.gnu.org/bugzilla/>
References: <bug-59414-4@http.gcc.gnu.org/bugzilla/>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/
Auto-Submitted: auto-generated
MIME-Version: 1.0
X-SW-Source: 2013-12/txt/msg00599.txt.bz2
Content-length: 985

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

--- Comment #3 from janus at gcc dot gnu.org ---
(In reply to janus from comment #2)
> With the patch the reduced test case in comment 1 compiles cleanly, but the
> full code in comment 0 then gives an ICE on a different location:
> 
> ObjectLists.f90: In function ‘addarray’:
> ObjectLists.f90:240:0: internal compiler error: in gfc_conv_expr_descriptor,
> at fortran/trans-array.c:6473
>              allocate(Pt%P(1:SIZE(P)), source= P)


Here is a reduced test case for the ICE (which seems unrelated to the original
error):


module ObjectLists
  implicit none

  type :: t
  end type

  type Object_array_pointer
    class(t), pointer :: p(:)
  end type

contains

  subroutine AddArray (P, Pt)
    class(t) :: P(:)
    class(Object_array_pointer) :: Pt

    select type (Pt)
    class is (Object_array_pointer)
      allocate(Pt%P(1:SIZE(P)), source=P)
    end select
  end subroutine

end module
>From gcc-bugs-return-436945-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Sat Dec 07 12:30:23 2013
Return-Path: <gcc-bugs-return-436945-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 20505 invoked by alias); 7 Dec 2013 12:30:23 -0000
Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm
Precedence: bulk
List-Id: <gcc-bugs.gcc.gnu.org>
List-Archive: <http://gcc.gnu.org/ml/gcc-bugs/>
List-Post: <mailto:gcc-bugs@gcc.gnu.org>
List-Help: <mailto:gcc-bugs-help@gcc.gnu.org>
Sender: gcc-bugs-owner@gcc.gnu.org
Delivered-To: mailing list gcc-bugs@gcc.gnu.org
Received: (qmail 20440 invoked by uid 48); 7 Dec 2013 12:30:18 -0000
From: "janus at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug fortran/59414] [OOP] Class array pointers: compile error on valid code (Different ranks in pointer assignment)
Date: Sat, 07 Dec 2013 12:30:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: fortran
X-Bugzilla-Version: 4.8.2
X-Bugzilla-Keywords: rejects-valid
X-Bugzilla-Severity: blocker
X-Bugzilla-Who: janus at gcc dot gnu.org
X-Bugzilla-Status: NEW
X-Bugzilla-Priority: P3
X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org
X-Bugzilla-Target-Milestone: ---
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields:
Message-ID: <bug-59414-4-b3csLU7VxY@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-59414-4@http.gcc.gnu.org/bugzilla/>
References: <bug-59414-4@http.gcc.gnu.org/bugzilla/>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: 7bit
X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/
Auto-Submitted: auto-generated
MIME-Version: 1.0
X-SW-Source: 2013-12/txt/msg00600.txt.bz2
Content-length: 298

http://gcc.gnu.org/bugzilla/show_bug.cgi?idY414

--- Comment #4 from janus at gcc dot gnu.org ---
Btw, when using the second (commented-out) version of 'AddArray' (which
apparently crashes with ifort), the full code in comment 0 compiles cleanly
with gfortran trunk plus the patch in comment 2.


  parent reply	other threads:[~2013-12-07 11:56 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-06 18:53 [Bug fortran/59414] New: " antony at cosmologist dot info
2013-12-07 11:12 ` [Bug fortran/59414] [OOP] " janus at gcc dot gnu.org
2013-12-07 11:56 ` janus at gcc dot gnu.org [this message]
2013-12-07 12:33 ` antony at cosmologist dot info
2013-12-07 12:46 ` janus at gcc dot gnu.org
2013-12-07 14:04 ` dominiq at lps dot ens.fr
2013-12-07 14:26 ` janus at gcc dot gnu.org
2013-12-07 15:13 ` janus at gcc dot gnu.org
2013-12-07 16:59 ` kargl at gcc dot gnu.org
2013-12-07 19:27 ` janus at gcc dot gnu.org
2013-12-07 19:30 ` janus at gcc dot gnu.org
2013-12-19 15:21 ` [Bug fortran/59414] [4.8/4.9 Regression] [OOP] ICE in in gfc_conv_expr_descriptor on ALLOCATE inside SELECT TYPE rguenth at gcc dot gnu.org
2014-01-19 12:34 ` pault at gcc dot gnu.org
2014-01-19 21:06 ` pault at gcc dot gnu.org
2014-01-26 14:31 ` mikael at gcc dot gnu.org
2014-01-26 17:41 ` paul.richard.thomas at gmail dot com
2014-01-28 20:11 ` pault at gcc dot gnu.org
2014-01-28 20:18 ` [Bug fortran/59414] [4.8 " pault at gcc dot gnu.org
2014-02-01 22:32 ` pault at gcc dot gnu.org
2014-02-01 22:34 ` pault 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-59414-4-Ui3vjmpwtJ@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).