From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 19463 invoked by alias); 4 Mar 2010 16:04:21 -0000 Received: (qmail 16570 invoked by uid 48); 4 Mar 2010 16:04:06 -0000 Date: Thu, 04 Mar 2010 16:04:00 -0000 Message-ID: <20100304160406.16562.qmail@sourceware.org> X-Bugzilla-Reason: CC References: Subject: [Bug fortran/43256] [OOP] character-valued TBP with missing optional arg In-Reply-To: Reply-To: gcc-bugzilla@gcc.gnu.org To: gcc-bugs@gcc.gnu.org From: "janus at gcc dot gnu dot org" Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2010-03/txt/msg00386.txt.bz2 ------- Comment #1 from janus at gcc dot gnu dot org 2010-03-04 16:04 ------- (In reply to comment #0) > Apparently this only happens for type-bound character-valued functions (but not > for subroutines or e.g. integer-valued functions). Actually that is wrong. It does work with subroutines, but it fails with all sorts of functions, also integer-valued ones, and with NOPASS: module module_myobj implicit none type :: myobj contains procedure, nopass :: myfunc end type contains integer function myfunc(status) integer, optional :: status if (present(status)) then write (*,*) 'myfunc: status is present.' else write (*,*) 'myfunc: status is not present.' end if myfunc = 1 end function end module program test_optional use :: module_myobj implicit none integer :: res,status type(myobj) :: myinstance res = myfunc() ! OK res = myfunc(status) ! OK res = myinstance%myfunc() ! FAILED res = myinstance%myfunc(status) ! OK end program For checking if it works, one should not only look at the output of the program, since this could be correct by chance. Instead, one should look at the dump, to see if a zero is passed for the missing optional arg. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43256