This is the mail archive of the fortran@gcc.gnu.org mailing list for the GNU Fortran project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Problem with optional argument in type-bound, character-valued function


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]