public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/107441] New: optional arguments are identified as "present" when missing
@ 2022-10-27 17:56 kaiserkarl31 at yahoo dot com
  2022-10-27 18:41 ` [Bug fortran/107441] " anlauf at gcc dot gnu.org
                   ` (12 more replies)
  0 siblings, 13 replies; 14+ messages in thread
From: kaiserkarl31 at yahoo dot com @ 2022-10-27 17:56 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107441

            Bug ID: 107441
           Summary: optional arguments are identified as "present" when
                    missing
           Product: gcc
           Version: 12.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: kaiserkarl31 at yahoo dot com
  Target Milestone: ---

If the first argument to a function is of type "character" (of any length, from
what I can tell, including ":" and "*") and the second parameter is both passed
by value and optional, the second argument will be identified as "present" even
when absent. The following short program reproduces the problem with gfortran
12.2.1:

program bugdemo

   implicit none
   character :: s
   integer :: t

   s = 'a'
   t = testoptional(s)
   print*, 'testoptional: ', t

contains

   function testoptional(w, x) result(t)

      character, intent(in) :: w
      integer, intent(in), value, optional :: x
      integer :: t

      print*, 'present(x) is ', present(x)
      t = 0

   end function testoptional

end program bugdemo
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

When compiled and run with gfortran 12.2.1, this gives the following output:
 present(x) is  T
 testoptional:            0
[clearly, the first line should have "F" instead of "T"]

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2023-04-08 18:39 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-27 17:56 [Bug fortran/107441] New: optional arguments are identified as "present" when missing kaiserkarl31 at yahoo dot com
2022-10-27 18:41 ` [Bug fortran/107441] " anlauf at gcc dot gnu.org
2022-10-27 18:52 ` kargl at gcc dot gnu.org
2022-10-27 19:20 ` anlauf at gcc dot gnu.org
2022-10-27 19:42 ` anlauf at gcc dot gnu.org
2022-10-27 19:49 ` anlauf at gcc dot gnu.org
2022-10-27 20:07 ` anlauf at gcc dot gnu.org
2022-10-27 20:52 ` anlauf at gcc dot gnu.org
2022-10-27 21:11 ` anlauf at gcc dot gnu.org
2022-10-27 21:56 ` sgk at troutmask dot apl.washington.edu
2022-10-28 20:13 ` anlauf at gcc dot gnu.org
2022-11-09 19:56 ` cvs-commit at gcc dot gnu.org
2022-12-06 18:39 ` anlauf at gcc dot gnu.org
2023-04-08 18:39 ` anlauf at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).