https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79312

kargl at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |kargl at gcc dot gnu.org

--- Comment #3 from kargl at gcc dot gnu.org ---
(In reply to john.harper from comment #0)
> This program violates f2008 syntax rule 7.2.1.2(4) but gfortran 6.1.1 on an
> x86-64 system compiles and runs it, printing 0
> 
>    program emptyarray5
>     implicit none
>     real a(0)
>     a = [logical::]
>     print *,size(a)
>   end program emptyarray5
> 
> ! f2008 7.2.1.2 (4) if the variable is polymorphic it shall be type
> ! compatible with expr ; otherwise the declared types of the variable and
> ! expr shall conform as specified in Table 7.8,
> !
> ! Table 7.8: Type conformance for the intrinsic assignment statement
> !
> ! Type of the variable | Type of expr
> !-----------------------------------------------------------+
> !   integer            |       integer, real, complex       |
> !     real             |       integer, real, complex       |
> !   complex            |       integer, real, complex       |
> !  character           |              character             |
> !   logical            |               logical              |
> !  derived type        |  same derived type as the variable |
> !-----------------------------------------------------------+

Index: resolve.c
===================================================================
--- resolve.c   (revision 245068)
+++ resolve.c   (working copy)
@@ -9911,6 +9911,13 @@ resolve_ordinary_assign (gfc_code *code,
   lhs = code->expr1;
   rhs = code->expr2;

+  if (rhs->ts.type == BT_LOGICAL  && lhs->ts.type != BT_LOGICAL)
+    {
+      gfc_error ("LOGICAL expression at %L assigned to a non-LOGICAL entity",
+                &rhs->where);
+      return false;
+    }
+
   if (rhs->is_boz
       && !gfc_notify_std (GFC_STD_GNU, "BOZ literal at %L outside "
                          "a DATA statement and outside INT/REAL/DBLE/CMPLX",

Reply via email to