public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/47728] New: Assigning an object of one type to a class variable leads to an ICE
@ 2011-02-14  9:00 arjen.markus at deltares dot nl
  2011-02-14 10:09 ` [Bug fortran/47728] [OOP] ICE on invalid CLASS declaration janus at gcc dot gnu.org
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: arjen.markus at deltares dot nl @ 2011-02-14  9:00 UTC (permalink / raw)
  To: gcc-bugs

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

           Summary: Assigning an object of one type to a class variable
                    leads to an ICE
           Product: gcc
           Version: 4.6.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: arjen.markus@deltares.nl


The following program produces an internal compiler error:

program test_objects

   implicit none

   type, abstract :: shape
   end type

   type, extends(shape) :: rectangle
       real :: width, height
   end type

   class(shape), dimension(2) :: object

   object(1) = rectangle( 1.0, 2.0 )

end program test_objects

There is no indication as to what is wrong with the program
(as Janus, who reduced my original program to this minimal one, remarks:
there are at least two)


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

* [Bug fortran/47728] [OOP] ICE on invalid CLASS declaration
  2011-02-14  9:00 [Bug fortran/47728] New: Assigning an object of one type to a class variable leads to an ICE arjen.markus at deltares dot nl
@ 2011-02-14 10:09 ` janus at gcc dot gnu.org
  2011-02-14 10:12 ` janus at gcc dot gnu.org
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: janus at gcc dot gnu.org @ 2011-02-14 10:09 UTC (permalink / raw)
  To: gcc-bugs

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

janus at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
           Keywords|                            |ice-on-invalid-code
   Last reconfirmed|                            |2011.02.14 10:06:20
                 CC|                            |janus at gcc dot gnu.org
     Ever Confirmed|0                           |1
            Summary|Assigning an object of one  |[OOP] ICE on invalid CLASS
                   |type to a class variable    |declaration
                   |leads to an ICE             |

--- Comment #1 from janus at gcc dot gnu.org 2011-02-14 10:06:20 UTC ---
Removing the last line ("object(1) = rectangle ..."), one gets:

   class(shape), dimension(2) :: object
                                       1
Error: CLASS variable 'object' at (1) must be dummy, allocatable or pointer


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

* [Bug fortran/47728] [OOP] ICE on invalid CLASS declaration
  2011-02-14  9:00 [Bug fortran/47728] New: Assigning an object of one type to a class variable leads to an ICE arjen.markus at deltares dot nl
  2011-02-14 10:09 ` [Bug fortran/47728] [OOP] ICE on invalid CLASS declaration janus at gcc dot gnu.org
@ 2011-02-14 10:12 ` janus at gcc dot gnu.org
  2011-02-14 10:23 ` janus at gcc dot gnu.org
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: janus at gcc dot gnu.org @ 2011-02-14 10:12 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from janus at gcc dot gnu.org 2011-02-14 10:09:15 UTC ---
Fixing up the CLASS declaration with the ALLOCATABLE attribute yields:

   class(shape), dimension(2), allocatable :: object
                                                    1
Error: Polymorphic array at (1) not yet supported


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

* [Bug fortran/47728] [OOP] ICE on invalid CLASS declaration
  2011-02-14  9:00 [Bug fortran/47728] New: Assigning an object of one type to a class variable leads to an ICE arjen.markus at deltares dot nl
  2011-02-14 10:09 ` [Bug fortran/47728] [OOP] ICE on invalid CLASS declaration janus at gcc dot gnu.org
  2011-02-14 10:12 ` janus at gcc dot gnu.org
@ 2011-02-14 10:23 ` janus at gcc dot gnu.org
  2011-02-14 10:27 ` dominiq at lps dot ens.fr
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: janus at gcc dot gnu.org @ 2011-02-14 10:23 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from janus at gcc dot gnu.org 2011-02-14 10:16:33 UTC ---
(In reply to comment #3)
> shouldn't that read:
> 
> class(shape), dimension(:), allocatable :: object
>                          ^
>                          | no fixed dimension

Yes, in principle it should. However, currently we boldly reject any kind of
dimensionful class variable, before even getting to the point of checking the
dimensions.


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

* [Bug fortran/47728] [OOP] ICE on invalid CLASS declaration
  2011-02-14  9:00 [Bug fortran/47728] New: Assigning an object of one type to a class variable leads to an ICE arjen.markus at deltares dot nl
                   ` (2 preceding siblings ...)
  2011-02-14 10:23 ` janus at gcc dot gnu.org
@ 2011-02-14 10:27 ` dominiq at lps dot ens.fr
  2011-02-14 12:24 ` janus at gcc dot gnu.org
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: dominiq at lps dot ens.fr @ 2011-02-14 10:27 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from Dominique d'Humieres <dominiq at lps dot ens.fr> 2011-02-14 10:23:49 UTC ---
> Error: Polymorphic array at (1) not yet supported

I wonder if this should not be a fatal error: if a feature is not implemented,
it is likely to trigger several side effects (such as extra errors and ICEs,
e.g., pr41600).


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

* [Bug fortran/47728] [OOP] ICE on invalid CLASS declaration
  2011-02-14  9:00 [Bug fortran/47728] New: Assigning an object of one type to a class variable leads to an ICE arjen.markus at deltares dot nl
                   ` (3 preceding siblings ...)
  2011-02-14 10:27 ` dominiq at lps dot ens.fr
@ 2011-02-14 12:24 ` janus at gcc dot gnu.org
  2011-02-14 14:06 ` janus at gcc dot gnu.org
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: janus at gcc dot gnu.org @ 2011-02-14 12:24 UTC (permalink / raw)
  To: gcc-bugs

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

janus at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
         AssignedTo|unassigned at gcc dot       |janus at gcc dot gnu.org
                   |gnu.org                     |

--- Comment #8 from janus at gcc dot gnu.org 2011-02-14 12:23:00 UTC ---
Ok, here is a simple draft patch which gets rid of the ICE:

Index: gcc/fortran/primary.c
===================================================================
--- gcc/fortran/primary.c       (revision 170124)
+++ gcc/fortran/primary.c       (working copy)
@@ -1770,8 +1770,8 @@ gfc_match_varspec (gfc_expr *primary, int equiv_fl

   if ((equiv_flag && gfc_peek_ascii_char () == '(')
       || gfc_peek_ascii_char () == '[' || sym->attr.codimension
-      || (sym->attr.dimension && !sym->attr.proc_pointer
-         && !gfc_is_proc_ptr_comp (primary, NULL)
+      || (sym->attr.dimension && sym->ts.type != BT_CLASS
+         && !sym->attr.proc_pointer && !gfc_is_proc_ptr_comp (primary, NULL)
          && !(gfc_matching_procptr_assignment
               && sym->attr.flavor == FL_PROCEDURE))
       || (sym->ts.type == BT_CLASS && sym->attr.class_ok


If this survives the testsuite, I will commit it as obvious.


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

* [Bug fortran/47728] [OOP] ICE on invalid CLASS declaration
  2011-02-14  9:00 [Bug fortran/47728] New: Assigning an object of one type to a class variable leads to an ICE arjen.markus at deltares dot nl
                   ` (4 preceding siblings ...)
  2011-02-14 12:24 ` janus at gcc dot gnu.org
@ 2011-02-14 14:06 ` janus at gcc dot gnu.org
  2011-02-14 18:17 ` janus at gcc dot gnu.org
  2011-02-14 18:18 ` janus at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: janus at gcc dot gnu.org @ 2011-02-14 14:06 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #9 from janus at gcc dot gnu.org 2011-02-14 13:57:55 UTC ---
(In reply to comment #8)
> If this survives the testsuite, I will commit it as obvious.

Regtest successful. Will commit shortly.


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

* [Bug fortran/47728] [OOP] ICE on invalid CLASS declaration
  2011-02-14  9:00 [Bug fortran/47728] New: Assigning an object of one type to a class variable leads to an ICE arjen.markus at deltares dot nl
                   ` (5 preceding siblings ...)
  2011-02-14 14:06 ` janus at gcc dot gnu.org
@ 2011-02-14 18:17 ` janus at gcc dot gnu.org
  2011-02-14 18:18 ` janus at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: janus at gcc dot gnu.org @ 2011-02-14 18:17 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #10 from janus at gcc dot gnu.org 2011-02-14 18:12:59 UTC ---
Author: janus
Date: Mon Feb 14 18:12:55 2011
New Revision: 170144

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

    PR fortran/47728
    * class.c (gfc_build_class_symbol): Give a fatal error on polymorphic
    arrays.
    * primary.c (gfc_match_varspec): Avoid ICE for invalid class
    declaration.

2011-02-14  Janus Weil  <janus@gcc.gnu.org>

    PR fortran/47728
    * gfortran.dg/class_38.f03: New.

Added:
    trunk/gcc/testsuite/gfortran.dg/class_38.f03
Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/class.c
    trunk/gcc/fortran/primary.c
    trunk/gcc/testsuite/ChangeLog


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

* [Bug fortran/47728] [OOP] ICE on invalid CLASS declaration
  2011-02-14  9:00 [Bug fortran/47728] New: Assigning an object of one type to a class variable leads to an ICE arjen.markus at deltares dot nl
                   ` (6 preceding siblings ...)
  2011-02-14 18:17 ` janus at gcc dot gnu.org
@ 2011-02-14 18:18 ` janus at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: janus at gcc dot gnu.org @ 2011-02-14 18:18 UTC (permalink / raw)
  To: gcc-bugs

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

janus at gcc dot gnu.org changed:

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

--- Comment #11 from janus at gcc dot gnu.org 2011-02-14 18:17:28 UTC ---
Fixed with r170144. I also followed Dominique's suggestion to reject
polymorphic errors with a fatal error.

Closing.


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

end of thread, other threads:[~2011-02-14 18:17 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-02-14  9:00 [Bug fortran/47728] New: Assigning an object of one type to a class variable leads to an ICE arjen.markus at deltares dot nl
2011-02-14 10:09 ` [Bug fortran/47728] [OOP] ICE on invalid CLASS declaration janus at gcc dot gnu.org
2011-02-14 10:12 ` janus at gcc dot gnu.org
2011-02-14 10:23 ` janus at gcc dot gnu.org
2011-02-14 10:27 ` dominiq at lps dot ens.fr
2011-02-14 12:24 ` janus at gcc dot gnu.org
2011-02-14 14:06 ` janus at gcc dot gnu.org
2011-02-14 18:17 ` janus at gcc dot gnu.org
2011-02-14 18:18 ` 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).