This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
Re: Problem with optional argument in type-bound, character-valued function
- From: Janus Weil <janus at gcc dot gnu dot org>
- To: P C <pchwood at yahoo dot com>
- Cc: fortran at gcc dot gnu dot org
- Date: Thu, 4 Mar 2010 15:10:04 +0100
- Subject: Re: Problem with optional argument in type-bound, character-valued function
- References: <556440.70347.qm@web63101.mail.re1.yahoo.com>
Hi,
> unless I am doing something wrong, the following test case shows that a missing optional argument in a type-bound, character-valued function is not detected as such.
> The problem does not happen for subroutine or integer functions.!?!
> By running the program 'test_optional', the output is
> ?myfunc1: status is not present.
> ?myfunc1: status is present.
> ?myfunc2: status is present.
> ?myfunc2: status is present.
>
> instead of
> ?myfunc1: status is not present.
> ?myfunc1: status is present.
> ?myfunc2: status is not present.
> ?myfunc2: status is present.
>
> I am using gcc version 4.5.0 20100119 (experimental)
Thanks for reporting. I can reproduce this behavior with today's
trunk. It definitely looks like a bug in gfortran. Do you feel brave
enough to open a PR for this in bugzilla? [Or should I do it for you?]
Regarding the origin of this bug, -fdump-tree-original shows the
following for your four calls:
myfunc1 ((character(kind=1)[1:80] *) &str.5, 80, &class.4, 0B);
myfunc1 ((character(kind=1)[1:80] *) &str.7, 80, &class.6, &status);
myfunc2 ((character(kind=1)[1:80] *) &str.9, 80, &class.8);
myfunc2 ((character(kind=1)[1:80] *) &str.11, 80, &class.10, &status);
So, it seems like we fail to pass a NULL pointer for the missing
optional arg in the third case. I think this should not be too hard to
fix.
Cheers,
Janus