public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/58916] New: Allocation of a class(*) scalar with array source allowed
@ 2013-10-29 22:12 vladimir.fuka at gmail dot com
  2013-12-09 11:02 ` [Bug fortran/58916] Allocation of scalar with array source not rejected janus at gcc dot gnu.org
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: vladimir.fuka at gmail dot com @ 2013-10-29 22:12 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 58916
           Summary: Allocation of a class(*) scalar with array source
                    allowed
           Product: gcc
           Version: 4.8.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: vladimir.fuka at gmail dot com

class(*),allocatable :: a
 real b(1)
 allocate(a, source=b)
end

Does not cause any error.


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

* [Bug fortran/58916] Allocation of scalar with array source not rejected
  2013-10-29 22:12 [Bug fortran/58916] New: Allocation of a class(*) scalar with array source allowed vladimir.fuka at gmail dot com
@ 2013-12-09 11:02 ` janus at gcc dot gnu.org
  2013-12-09 11:13 ` janus at gcc dot gnu.org
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: janus at gcc dot gnu.org @ 2013-12-09 11:02 UTC (permalink / raw)
  To: gcc-bugs

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

janus at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |ice-on-invalid-code
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2013-12-09
                 CC|                            |janus at gcc dot gnu.org
            Summary|Allocation of a class(*)    |Allocation of scalar with
                   |scalar with array source    |array source not rejected
                   |allowed                     |
     Ever confirmed|0                           |1

--- Comment #1 from janus at gcc dot gnu.org ---
Here is a variant without classes:

 real, allocatable :: a
 real b(1)
 allocate(a, source=b)
end

This is also not rejected, but gives an ICE (with 4.6 to 4.9).


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

* [Bug fortran/58916] Allocation of scalar with array source not rejected
  2013-10-29 22:12 [Bug fortran/58916] New: Allocation of a class(*) scalar with array source allowed vladimir.fuka at gmail dot com
  2013-12-09 11:02 ` [Bug fortran/58916] Allocation of scalar with array source not rejected janus at gcc dot gnu.org
@ 2013-12-09 11:13 ` janus at gcc dot gnu.org
  2013-12-09 11:30 ` janus at gcc dot gnu.org
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: janus at gcc dot gnu.org @ 2013-12-09 11:13 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from janus at gcc dot gnu.org ---
The following is sufficient to reject comment 1, but does not reject comment 0:

Index: gcc/fortran/resolve.c
===================================================================
--- gcc/fortran/resolve.c    (revision 205785)
+++ gcc/fortran/resolve.c    (working copy)
@@ -6594,7 +6594,8 @@ conformable_arrays (gfc_expr *e1, gfc_expr *e2)
   for (tail = e2->ref; tail && tail->next; tail = tail->next);

   /* First compare rank.  */
-  if (tail && e1->rank != tail->u.ar.as->rank)
+  if ((tail && e1->rank != tail->u.ar.as->rank)
+      || (!tail && e1->rank != e2->rank))
     {
       gfc_error ("Source-expr at %L must be scalar or have the "
          "same rank as the allocate-object at %L",


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

* [Bug fortran/58916] Allocation of scalar with array source not rejected
  2013-10-29 22:12 [Bug fortran/58916] New: Allocation of a class(*) scalar with array source allowed vladimir.fuka at gmail dot com
  2013-12-09 11:02 ` [Bug fortran/58916] Allocation of scalar with array source not rejected janus at gcc dot gnu.org
  2013-12-09 11:13 ` janus at gcc dot gnu.org
@ 2013-12-09 11:30 ` janus at gcc dot gnu.org
  2013-12-09 12:38 ` [Bug fortran/58916] [F03] " janus at gcc dot gnu.org
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: janus at gcc dot gnu.org @ 2013-12-09 11:30 UTC (permalink / raw)
  To: gcc-bugs

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

janus at gcc dot gnu.org changed:

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

--- Comment #3 from janus at gcc dot gnu.org ---
This updated patch rejects both test cases (but is not regtested yet):

Index: gcc/fortran/resolve.c
===================================================================
--- gcc/fortran/resolve.c    (revision 205785)
+++ gcc/fortran/resolve.c    (working copy)
@@ -6594,7 +6594,8 @@ conformable_arrays (gfc_expr *e1, gfc_expr *e2)
   for (tail = e2->ref; tail && tail->next; tail = tail->next);

   /* First compare rank.  */
-  if (tail && e1->rank != tail->u.ar.as->rank)
+  if ((tail && e1->rank != tail->u.ar.as->rank)
+      || (!tail && e1->rank != e2->rank))
     {
       gfc_error ("Source-expr at %L must be scalar or have the "
          "same rank as the allocate-object at %L",
@@ -6791,8 +6792,7 @@ resolve_allocate_expr (gfc_expr *e, gfc_code *code
     }

       /* Check F03:C632 and restriction following Note 6.18.  */
-      if (code->expr3->rank > 0 && !unlimited
-      && !conformable_arrays (code->expr3, e))
+      if (code->expr3->rank > 0 && !conformable_arrays (code->expr3, e))
     goto failure;

       /* Check F03:C633.  */


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

* [Bug fortran/58916] [F03] Allocation of scalar with array source not rejected
  2013-10-29 22:12 [Bug fortran/58916] New: Allocation of a class(*) scalar with array source allowed vladimir.fuka at gmail dot com
                   ` (2 preceding siblings ...)
  2013-12-09 11:30 ` janus at gcc dot gnu.org
@ 2013-12-09 12:38 ` janus at gcc dot gnu.org
  2013-12-09 15:58 ` janus at gcc dot gnu.org
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: janus at gcc dot gnu.org @ 2013-12-09 12:38 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from janus at gcc dot gnu.org ---
(In reply to janus from comment #3)
> This updated patch rejects both test cases

... and regtests cleanly (except for the current failure of PR 59428).


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

* [Bug fortran/58916] [F03] Allocation of scalar with array source not rejected
  2013-10-29 22:12 [Bug fortran/58916] New: Allocation of a class(*) scalar with array source allowed vladimir.fuka at gmail dot com
                   ` (3 preceding siblings ...)
  2013-12-09 12:38 ` [Bug fortran/58916] [F03] " janus at gcc dot gnu.org
@ 2013-12-09 15:58 ` janus at gcc dot gnu.org
  2013-12-09 15:59 ` janus at gcc dot gnu.org
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: janus at gcc dot gnu.org @ 2013-12-09 15:58 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from janus at gcc dot gnu.org ---
(In reply to janus from comment #1)
> Here is a variant without classes:
> 
>  real, allocatable :: a
>  real b(1)
>  allocate(a, source=b)
> end

I just noticed that this case has been filed as PR 58917.


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

* [Bug fortran/58916] [F03] Allocation of scalar with array source not rejected
  2013-10-29 22:12 [Bug fortran/58916] New: Allocation of a class(*) scalar with array source allowed vladimir.fuka at gmail dot com
                   ` (4 preceding siblings ...)
  2013-12-09 15:58 ` janus at gcc dot gnu.org
@ 2013-12-09 15:59 ` janus at gcc dot gnu.org
  2013-12-09 16:02 ` vladimir.fuka at gmail dot com
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: janus at gcc dot gnu.org @ 2013-12-09 15:59 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from janus at gcc dot gnu.org ---
*** Bug 58917 has been marked as a duplicate of this bug. ***


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

* [Bug fortran/58916] [F03] Allocation of scalar with array source not rejected
  2013-10-29 22:12 [Bug fortran/58916] New: Allocation of a class(*) scalar with array source allowed vladimir.fuka at gmail dot com
                   ` (5 preceding siblings ...)
  2013-12-09 15:59 ` janus at gcc dot gnu.org
@ 2013-12-09 16:02 ` vladimir.fuka at gmail dot com
  2013-12-11 14:02 ` janus at gcc dot gnu.org
  2013-12-11 14:05 ` janus at gcc dot gnu.org
  8 siblings, 0 replies; 10+ messages in thread
From: vladimir.fuka at gmail dot com @ 2013-12-09 16:02 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #7 from Vladimir Fuka <vladimir.fuka at gmail dot com> ---
Sorry,  didn't remember that.


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

* [Bug fortran/58916] [F03] Allocation of scalar with array source not rejected
  2013-10-29 22:12 [Bug fortran/58916] New: Allocation of a class(*) scalar with array source allowed vladimir.fuka at gmail dot com
                   ` (6 preceding siblings ...)
  2013-12-09 16:02 ` vladimir.fuka at gmail dot com
@ 2013-12-11 14:02 ` janus at gcc dot gnu.org
  2013-12-11 14:05 ` janus at gcc dot gnu.org
  8 siblings, 0 replies; 10+ messages in thread
From: janus at gcc dot gnu.org @ 2013-12-11 14:02 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #8 from janus at gcc dot gnu.org ---
Author: janus
Date: Wed Dec 11 14:02:44 2013
New Revision: 205894

URL: http://gcc.gnu.org/viewcvs?rev=205894&root=gcc&view=rev
Log:
2013-12-11  Janus Weil  <janus@gcc.gnu.org>

    PR fortran/58916
    * resolve.c (conformable_arrays): Treat scalar 'e2'.
    (resolve_allocate_expr): Check rank also for unlimited-polymorphic
    variables.


2013-12-11  Janus Weil  <janus@gcc.gnu.org>

    PR fortran/58916
    * gfortran.dg/allocate_with_source_4.f90: New.

Added:
    trunk/gcc/testsuite/gfortran.dg/allocate_with_source_4.f90
Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/resolve.c
    trunk/gcc/testsuite/ChangeLog


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

* [Bug fortran/58916] [F03] Allocation of scalar with array source not rejected
  2013-10-29 22:12 [Bug fortran/58916] New: Allocation of a class(*) scalar with array source allowed vladimir.fuka at gmail dot com
                   ` (7 preceding siblings ...)
  2013-12-11 14:02 ` janus at gcc dot gnu.org
@ 2013-12-11 14:05 ` janus at gcc dot gnu.org
  8 siblings, 0 replies; 10+ messages in thread
From: janus at gcc dot gnu.org @ 2013-12-11 14:05 UTC (permalink / raw)
  To: gcc-bugs

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

janus at gcc dot gnu.org changed:

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

--- Comment #9 from janus at gcc dot gnu.org ---
Fixed with r205894. Closing.

Thanks for the report!


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

end of thread, other threads:[~2013-12-11 14:05 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-10-29 22:12 [Bug fortran/58916] New: Allocation of a class(*) scalar with array source allowed vladimir.fuka at gmail dot com
2013-12-09 11:02 ` [Bug fortran/58916] Allocation of scalar with array source not rejected janus at gcc dot gnu.org
2013-12-09 11:13 ` janus at gcc dot gnu.org
2013-12-09 11:30 ` janus at gcc dot gnu.org
2013-12-09 12:38 ` [Bug fortran/58916] [F03] " janus at gcc dot gnu.org
2013-12-09 15:58 ` janus at gcc dot gnu.org
2013-12-09 15:59 ` janus at gcc dot gnu.org
2013-12-09 16:02 ` vladimir.fuka at gmail dot com
2013-12-11 14:02 ` janus at gcc dot gnu.org
2013-12-11 14:05 ` 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).