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

            Bug ID: 121727
           Summary: Missed optimization passing character actual to
                    shorter dummy with value attribute
           Product: gcc
           Version: 16.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: anlauf at gcc dot gnu.org
  Target Milestone: ---

Created attachment 62240
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=62240&action=edit
Testcase

Spin-off from pr93330 (see original testcase by Tobias Burnus):

program p
  call two('1234')
contains
  subroutine two(x)
    character(kind=1,len=2), value :: x
  end
end

This translates to:

void p ()
{
  static void two (character(kind=1)[1:2], integer(kind=8));

  two ("1234", 4);
}

It would be sufficient to pass only the first two characters.

Note that we fully optimize for len=1 value dummies, but not others.

More complete testcase attached.

Reply via email to