public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/54778] New: an ICE on invalid OO code
@ 2012-10-02  9:50 slayoo at staszic dot waw.pl
  2012-10-02 16:13 ` [Bug fortran/54778] [OOP] " janus at gcc dot gnu.org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: slayoo at staszic dot waw.pl @ 2012-10-02  9:50 UTC (permalink / raw)
  To: gcc-bugs


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

             Bug #: 54778
           Summary: an ICE on invalid OO code
    Classification: Unclassified
           Product: gcc
           Version: 4.8.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: slayoo@staszic.waw.pl


Hi, 

Enclosing below the steps to reproduce an ICE on an invalid OO code.

HTH,
Sylwester



$ cat bug.f95 
module bug_m
  implicit none

  type :: arr_t
    real, dimension(:,:), pointer :: at
  end type

  type :: bug_t
    class(arr_t), allocatable :: elements(:)
  end type

  contains

  function elem(this, i)
    type(bug_t), intent(in) :: this
    integer, intent(in) :: i
    class(arr_t) :: elem
    elem = this%elements(i)
  end function
end module

$ /usr/lib/gcc-snapshot/bin/gfortran bug.f95 
bug.f95:14.2:

  function elem(this, i)
  1
Error: CLASS variable 'elem' at (1) must be dummy, allocatable or pointer
f951: internal compiler error: Segmentation fault
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-snapshot/README.Bugs> for instructions.

$ /usr/lib/gcc-snapshot/bin/gfortran --version
GNU Fortran (Debian 20120930-1) 4.8.0 20120930 (experimental) [trunk revision
191865]
Copyright (C) 2012 Free Software Foundation, Inc.

GNU Fortran comes with NO WARRANTY, to the extent permitted by law.
You may redistribute copies of GNU Fortran
under the terms of the GNU General Public License.
For more information about these matters, see the file named COPYING


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

* [Bug fortran/54778] [OOP] an ICE on invalid OO code
  2012-10-02  9:50 [Bug fortran/54778] New: an ICE on invalid OO code slayoo at staszic dot waw.pl
@ 2012-10-02 16:13 ` janus at gcc dot gnu.org
  2012-10-02 19:00 ` janus at gcc dot gnu.org
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: janus at gcc dot gnu.org @ 2012-10-02 16:13 UTC (permalink / raw)
  To: gcc-bugs


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

janus at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |ASSIGNED
           Keywords|                            |ice-on-invalid-code
   Last reconfirmed|                            |2012-10-02
                 CC|                            |janus at gcc dot gnu.org
         AssignedTo|unassigned at gcc dot       |janus at gcc dot gnu.org
                   |gnu.org                     |
     Ever Confirmed|0                           |1
            Summary|an ICE on invalid OO code   |[OOP] an ICE on invalid OO
                   |                            |code

--- Comment #1 from janus at gcc dot gnu.org 2012-10-02 16:12:50 UTC ---
Thanks for reporting. I can reproduce this on 4.7 and trunk.


Here is a patch to fix it:

Index: gcc/fortran/interface.c
===================================================================
--- gcc/fortran/interface.c    (revision 191869)
+++ gcc/fortran/interface.c    (working copy)
@@ -3386,7 +3386,8 @@ matching_typebound_op (gfc_expr** tb_base,

     if (base->expr->ts.type == BT_CLASS)
       {
-        if (CLASS_DATA (base->expr) == NULL)
+        if (CLASS_DATA (base->expr) == NULL
+        || !gfc_expr_attr (base->expr).class_ok)
           continue;
         derived = CLASS_DATA (base->expr)->ts.u.derived;
       }


With this I get:

c0.f90:14.2:

  function elem(this, i)
  1
Error: CLASS variable 'elem' at (1) must be dummy, allocatable or pointer
c0.f90:18.4:

    elem = this%elements(i)
    1
Error: Variable must not be polymorphic in intrinsic assignment at (1) - check
that there is a matching specific subroutine for '=' operator


Regtesting now ...


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

* [Bug fortran/54778] [OOP] an ICE on invalid OO code
  2012-10-02  9:50 [Bug fortran/54778] New: an ICE on invalid OO code slayoo at staszic dot waw.pl
  2012-10-02 16:13 ` [Bug fortran/54778] [OOP] " janus at gcc dot gnu.org
@ 2012-10-02 19:00 ` janus at gcc dot gnu.org
  2012-10-02 19:31 ` janus at gcc dot gnu.org
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: janus at gcc dot gnu.org @ 2012-10-02 19:00 UTC (permalink / raw)
  To: gcc-bugs


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

--- Comment #2 from janus at gcc dot gnu.org 2012-10-02 19:00:34 UTC ---
(In reply to comment #1)
> Regtesting now ...

Finished successfully. Will commit as obvious.


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

* [Bug fortran/54778] [OOP] an ICE on invalid OO code
  2012-10-02  9:50 [Bug fortran/54778] New: an ICE on invalid OO code slayoo at staszic dot waw.pl
  2012-10-02 16:13 ` [Bug fortran/54778] [OOP] " janus at gcc dot gnu.org
  2012-10-02 19:00 ` janus at gcc dot gnu.org
@ 2012-10-02 19:31 ` janus at gcc dot gnu.org
  2012-10-02 21:02 ` janus at gcc dot gnu.org
  2012-10-02 21:07 ` janus at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: janus at gcc dot gnu.org @ 2012-10-02 19:31 UTC (permalink / raw)
  To: gcc-bugs


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

--- Comment #3 from janus at gcc dot gnu.org 2012-10-02 19:31:40 UTC ---
Btw, here is a slightly simpler version of the test case with the same
symptoms:


implicit none

type :: arr_t
  real :: at
end type

type(arr_t) :: this
class(arr_t) :: elem

elem = this

end


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

* [Bug fortran/54778] [OOP] an ICE on invalid OO code
  2012-10-02  9:50 [Bug fortran/54778] New: an ICE on invalid OO code slayoo at staszic dot waw.pl
                   ` (2 preceding siblings ...)
  2012-10-02 19:31 ` janus at gcc dot gnu.org
@ 2012-10-02 21:02 ` janus at gcc dot gnu.org
  2012-10-02 21:07 ` janus at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: janus at gcc dot gnu.org @ 2012-10-02 21:02 UTC (permalink / raw)
  To: gcc-bugs


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

--- Comment #4 from janus at gcc dot gnu.org 2012-10-02 21:02:20 UTC ---
Author: janus
Date: Tue Oct  2 21:02:16 2012
New Revision: 192005

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=192005
Log:
2012-10-02  Janus Weil  <janus@gcc.gnu.org>

    PR fortran/54778
    * interface.c (matching_typebound_op): Check for 'class_ok' attribute.

2012-10-02  Janus Weil  <janus@gcc.gnu.org>

    PR fortran/54778
    * gfortran.dg/class_53.f90: New.

Added:
    trunk/gcc/testsuite/gfortran.dg/class_53.f90
Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/interface.c
    trunk/gcc/testsuite/ChangeLog


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

* [Bug fortran/54778] [OOP] an ICE on invalid OO code
  2012-10-02  9:50 [Bug fortran/54778] New: an ICE on invalid OO code slayoo at staszic dot waw.pl
                   ` (3 preceding siblings ...)
  2012-10-02 21:02 ` janus at gcc dot gnu.org
@ 2012-10-02 21:07 ` janus at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: janus at gcc dot gnu.org @ 2012-10-02 21:07 UTC (permalink / raw)
  To: gcc-bugs


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

janus at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED

--- Comment #5 from janus at gcc dot gnu.org 2012-10-02 21:07:43 UTC ---
Fixed with r192005. Closing.

Thanks again for the report!


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

end of thread, other threads:[~2012-10-02 21:07 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-10-02  9:50 [Bug fortran/54778] New: an ICE on invalid OO code slayoo at staszic dot waw.pl
2012-10-02 16:13 ` [Bug fortran/54778] [OOP] " janus at gcc dot gnu.org
2012-10-02 19:00 ` janus at gcc dot gnu.org
2012-10-02 19:31 ` janus at gcc dot gnu.org
2012-10-02 21:02 ` janus at gcc dot gnu.org
2012-10-02 21:07 ` janus 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).