[Patch, Fortran] PR35203 - Fix VALUE + OPTIONAL handling for pass-by-value arguments

Tobias Burnus burnus@net-b.de
Thu Mar 21 18:02:00 GMT 2013

Dear all,

using VALUE, gfortran passes the arguments by value.* That works well, 
except if VALUE is combined with OPTIONAL. Currently, "call foo(0)" and 
"call foo()" are indistinguishable.

With this patch, a hidden argument is added which includes the present 
information. I think that's the least intrusive version which also has 
the performance advantage of continuing to use pass-by-value semantics.

Build and regtested on x86-64-gnu-linux.
OK for the trunk?


PS: At some point, we need to handle VALUE with arrays, derived types 
and class. For those, one should pass by reference, doing a copy in. In 
that case, using the NULL-pointer check for present() should work. (PR 

* Except for character. (Note: value+optional for characters currently 
fails with an ICE, also tracked at PR 49802.)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: optional_value.diff
Type: text/x-patch
Size: 7575 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20130321/f7b405f2/attachment.bin>

More information about the Gcc-patches mailing list