[Bug fortran/82995] Segmentation fault passing optional argument to intrinsic sum function
kargl at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Tue Nov 14 22:07:00 GMT 2017
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82995
kargl at gcc dot gnu.org changed:
What |Removed |Added
----------------------------------------------------------------------------
Priority|P3 |P4
Status|WAITING |NEW
CC| |kargl at gcc dot gnu.org
Target Milestone|--- |8.0
--- Comment #2 from kargl at gcc dot gnu.org ---
(In reply to Dominique d'Humieres from comment #1)
> IMO the code is invalid: you cannot call my_sum with only one argument. I
> get a segfault for all the revision I have tested from 4.8 up to trunk
> (8.0), except with my instrumented trunk for which I get 0.
>
> I am a little bit surprised that the mismatch between caller and callee is
> not detected, but I think a compiler does have to (I did not look at the
> standard legalese).
The code is valid. From 2008, page 299
An optional dummy argument that is not present is subject to the
following restrictions.
(1) If it is a data object, it shall not be referenced or be
defined. ...
...
Except as noted in the list above, it may be supplied as an actual
argument corresponding to an optional dummy argument, which is then
also considered not to be present.
By (1), one would think that the absent optional argument cannot
be referenced within my_sum(). However, the exception explicitly
allows this case as the MASK argument of SUM is optional.
More information about the Gcc-bugs
mailing list