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

            Bug ID: 78021
           Summary: Wrong result with optimization, character constant
           Product: gcc
           Version: 6.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: dcesari69 at gmail dot com
  Target Milestone: ---

The following simple code:

PROGRAM test_o_char
PRINT*,mylen('c')+mylen('c   ')

CONTAINS

FUNCTION mylen(c)
CHARACTER(len=*),INTENT(in) :: c
INTEGER :: mylen
mylen=LEN(c)
END FUNCTION mylen
END PROGRAM test_o_char

gives a wrong result (8 instead of 5) when compiled with -O1 or higher. It is
evident that a static optimisation does not take into account blank padding of
character constants and considers the two calls to mylen() equivalent.

GNU Fortran (GCC) 6.2.1 20160916 (Red Hat 6.2.1-2)
Copyright (C) 2016 Free Software Foundation, Inc.

Reply via email to