[Bug fortran/82995] Segmentation fault passing optional argument to intrinsic sum function
tkoenig at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Mon Dec 31 15:27:00 GMT 2018
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82995
Thomas Koenig <tkoenig at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution|--- |FIXED
--- Comment #13 from Thomas Koenig <tkoenig at gcc dot gnu.org> ---
This one is fixed.
The only (minor) thing is that, if the function result for SUM or
PRODUCT has rank >= 1, we fall back to the library version if
the MASK is passed as an absent optional argument.
Why? Well, the scalarized loop took its bounds from the
last argument pushed to the scalarizer, which was the mask.
If that mask was absent, it used uninitialized variables.
For the one-dimensional code, I was able to handle this
by reversing the order with this part of the patch:
- gfc_add_ss_to_loop (&loop, arrayss);
+
+ /* We add the mask first because the number of iterations is
+ taken from the last ss, and this breaks if an absent
+ optional argument is used for mask. */
+
if (maskexpr && maskexpr->rank > 0)
gfc_add_ss_to_loop (&loop, maskss);
+ gfc_add_ss_to_loop (&loop, arrayss);
For the multi-dimensional case, I tried to do so, but failed.
OTOH, the code is correct, and I doubt that generating inlined
code for this corner case is actually worth putting in the time.
So, closing.
More information about the Gcc-bugs
mailing list