This is the mail archive of the
mailing list for the GCC project.
Re: *ping* [Patch, Fortran] PR35203 - Fix VALUE + OPTIONAL handling for pass-by-value arguments
- From: Tobias Burnus <burnus at net-b dot de>
- To: gcc patches <gcc-patches at gcc dot gnu dot org>, gfortran <fortran at gcc dot gnu dot org>
- Date: Thu, 28 Mar 2013 22:33:15 +0100
- Subject: Re: *ping* [Patch, Fortran] PR35203 - Fix VALUE + OPTIONAL handling for pass-by-value arguments
- References: <514B4B2D dot 20201 at net-b dot de>
*ping* / http://gcc.gnu.org/ml/fortran/2013-03/msg00102.html
On March 21, 2013 19:02, Tobias Burnus wrote:
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.
* Except for character. (Note: value+optional for characters currently
fails with an ICE, also tracked at PR 49802.)