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
          Reporter: dcesari69 at gmail dot com
  Target Milestone: ---

The following simple code:

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


FUNCTION mylen(c)
CHARACTER(len=*),INTENT(in) :: c
INTEGER :: 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