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

            Bug ID: 92325
           Summary: -fdump-tree-original and char(kind=4) initializations
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: anlauf at gcc dot gnu.org
  Target Milestone: ---

While looking at a different PR, I noticed that the following code
produces unexpected output from -fdump-tree-original:

program p
  implicit none
  character(len=1,kind=4)            :: a1 = 4_'A'
  character(len=2,kind=4)            :: a2 = 4_'AB'
  character(len=3,kind=4)            :: a3 = 4_'ABC'
  print *, a1 // a2 // a3
end

gcc-10 & gcc-9 produce:

p ()
{
  static character(kind=4) a1[1:1] = "A\x00\x00";
  static character(kind=4) a2[1:2] = "A\x00\x00\x00B\x00\x00";
  static character(kind=4) a3[1:3] = "A\x00\x00\x00B\x00\x00\x00C\x00\x00";

...

while gcc-7 and gcc-8 produce:

p ()
{
  static character(kind=4) a1[1:1] = "A";
  static character(kind=4) a2[1:2] = "A";
  static character(kind=4) a3[1:3] = "A";


So gcc-7 and gcc-8 only display the first character of the initializer,
while gcc-9 and gcc-10 has initializers that appear to be one byte too
short, as they miss the final \x00 of the last character.

While this may be an entirely cosmetic issue, it would be helpful to have
this corrected.  Any idea where I should be looking to fix this?

Reply via email to