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

Thomas Koenig <tkoenig at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |wrong-code
   Last reconfirmed|2017-11-14 00:00:00         |2018-10-4

--- Comment #7 from Thomas Koenig <tkoenig at gcc dot gnu.org> ---
Part of the library part of this problem is in the following piece of code in
trans-expr.c (5632):

      if (e && (fsym == NULL || fsym->attr.optional))
        {
          /* If an optional argument is itself an optional dummy argument,
             check its presence and substitute a null if absent.  This is
             only needed when passing an array to an elemental procedure
             as then array elements are accessed - or no NULL pointer is
             allowed and a "1" or "0" should be passed if not present.

...

The comment (and the code which follows) is wrong for intrinsics
with an optional mask argument.  Of course, the library would also
have to handle that, but that is easily done with code like

Index: ifunction.m4
===================================================================
--- ifunction.m4        (Revision 264540)
+++ ifunction.m4        (Arbeitskopie)
@@ -210,6 +210,15 @@
   index_type mdelta;
   int mask_kind;

+  if (mask->base_addr == NULL)
+    {
+#ifdef HAVE_BACK_ARG
+      name`'rtype_qual`_'atype_code (retarray, array, pdim, back);
+#else
+      name`'rtype_qual`_'atype_code (retarray, array, pdim);
+#endif
+    }
+
   dim = (*pdim) - 1;
   rank = GFC_DESCRIPTOR_RANK (array) - 1;

(or "if (mask == NULL)", depending on how this works out.

Reply via email to