public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "kyle.shores44 at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug libfortran/108618] New: ISO C-Fortran Interface fails to pass CFI descriptor version check when using code coverage flags for fortran
Date: Tue, 31 Jan 2023 19:31:02 +0000	[thread overview]
Message-ID: <bug-108618-4@http.gcc.gnu.org/bugzilla/> (raw)

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

            Bug ID: 108618
           Summary: ISO C-Fortran Interface fails to pass CFI descriptor
                    version check when using code coverage flags for
                    fortran
           Product: gcc
           Version: 13.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libfortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: kyle.shores44 at gmail dot com
  Target Milestone: ---

Created attachment 54378
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=54378&action=edit
A zipped archive with 5 files, a dockerfile, CMakeLists.txt, a cmake file for
code coverage, a fortran source file, a c++ source file

The C-Fortran interface fails to pass a runtime Fortran check for the CFI
descriptor when checking code coverage. Specifically, the `-fcheck=bounds` flag
causes the runtime failure.

Included is a zip file that has a minimal working example. It's a cmake project
with two source files (one c++, one fortran), a Dockerfile, a CMakeLists.txt
file as well as the necessary code coverage cmake file. Fortran creates some
strings and passes them to C(++) through the `CFI_cdesc_t` struct defined in
ISO_Fortran_binding.h.

Inside of the CMakeLists.txt file there are two calls to
`set(CMAKE_Fortran_FLAGS ...`. Above each is a comment indicating which of the
flags passes and which fails. You can comment and uncomment the pair to watch
the created executable fail intermittently. 

When I compile the sources on my machine with the below versions of tools, I
see the failure.

os: macOS 12.5
architecture: Apple M1 Pro
gfortran: GNU Fortran (Homebrew GCC 12.2.0) 12.2.0
g++: (Homebrew GCC 12.2.0) 12.2.0
cmake: 3.25.1

I also see the failure in the Dockerfile included in the zipped archive
(hopefully this aids in the reproducibility of the issue). The tool versions in
the Dockerfile are

os: Fedora Linux 38
architecture: Apple M1 Pro
gfortran: GNU Fortran (GCC) 13.0.1 20230127 (Red Hat 13.0.1-0)
g++: (GCC) 13.0.1 20230127 (Red Hat 13.0.1-0)
cmake: 3.25.2

The specific flag that causes the issue is `-fcheck=bounds`.

The full list of compiler flags passed to gfortran on my machine:

/opt/homebrew/bin/gfortran 
-I/Users/kshores/Downloads/mwe/build/_deps/googletest-src/googletest/include
-I/Users/kshores/Downloads/mwe/build/_deps/googletest-src/googletest -g -O0
-fprofile-arcs -ftest-coverage -fcheck=bounds,do,pointer
-ffpe-trap=zero,overflow,invalid -fprofile-abs-path -isysroot
/Library/Developer/CommandLineTools/SDKs/MacOSX12.3.sdk -c
/Users/kshores/Downloads/mwe/fortran_strings.F90 -o
CMakeFiles/bad_version.dir/fortran_strings.F90.o

The full list of compiler flags passed to gfortran in the Dockerfile:

/usr/bin/gfortran  -I/build/_deps/googletest-src/googletest/include
-I/build/_deps/googletest-src/googletest -g -O0 -fprofile-arcs -ftest-coverage
-fcheck=bounds,do,pointer -ffpe-trap=zero,overflow,invalid -fprofile-abs-path
-c /mwe/fortran_strings.F90 -o CMakeFiles/bad_version.dir/fortran_strings.F90.o


I hope that this is enough information. Please let me know if there is more
that is needed from me.

             reply	other threads:[~2023-01-31 19:31 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-31 19:31 kyle.shores44 at gmail dot com [this message]
2023-01-31 19:38 ` [Bug libfortran/108618] " pinskia at gcc dot gnu.org
2023-01-31 19:39 ` pinskia at gcc dot gnu.org
2023-01-31 19:40 ` kyle.shores44 at gmail dot com
2023-01-31 19:41 ` pinskia at gcc dot gnu.org
2023-01-31 19:42 ` kyle.shores44 at gmail dot com
2023-01-31 19:54 ` kyle.shores44 at gmail dot com
2023-01-31 22:02 ` pinskia at gcc dot gnu.org
2023-01-31 22:25 ` pinskia at gcc dot gnu.org
2023-01-31 22:47 ` kyle.shores44 at gmail dot com
2023-01-31 22:49 ` pinskia at gcc dot gnu.org
2023-02-01 15:40 ` kyle.shores44 at gmail dot com

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-108618-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).