From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 5CA7B385840C; Mon, 24 Oct 2022 11:25:03 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 5CA7B385840C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1666610703; bh=GXtu6hFC2MUk6PgApdph1Kd2rUjcCHkSGaHmoViwoLo=; h=From:To:Subject:Date:From; b=SSXgH2ZcJ7xzA4m91lTsq0EC2EKHGYxN5erfAyq7Fi8XUppGl2Fe7Mg/Kfj3wlyqx eI6j7M7xydBjNrV1u8rXU/XfEtfidC9AOFYGYfl1Po092sSour3Z7vogda2yf4RsqK U7wJM3MDlbO8SFmNxcj6VgpxG8hAqFL/MV51a5lE= From: "jeff.science at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/107375] New: CFI_cdesc_t incorrectly reports non-interoperable C structure as such Date: Mon, 24 Oct 2022 11:25:02 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: fortran X-Bugzilla-Version: 12.2.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: jeff.science at gmail dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D107375 Bug ID: 107375 Summary: CFI_cdesc_t incorrectly reports non-interoperable C structure as such Product: gcc Version: 12.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: fortran Assignee: unassigned at gcc dot gnu.org Reporter: jeff.science at gmail dot com Target Milestone: --- Interoperable C structs are not permitted to contain allocatable members, a= mong other things. The compiler should report that types containing allocatable members are CFI_type_other, not CFI_type_struct. I was not sure if the Fortran code was illegal or if the CFI_cdesc_t was populated incorrectly, but another member of WG5 said it was the latter. % gcc-12 -g -std=3Dc11 -c foo.c -o foo.o % gfortran-12 -g -std=3Df2018 class.F90 foo.o -o class.x % ./class.x CFI_cdesc_t.type =3D interoperable C structure =3D=3D> foo.c <=3D=3D #include #include #include "ISO_Fortran_binding.h" char * get_type(CFI_type_t t) { switch(t) { case CFI_type_cptr : return "void *"; break; case CFI_type_struct : return "interoperable C structure"; break; case CFI_type_other : return "Not otherwise specified"; break; default : abort(); } } void foo(CFI_cdesc_t * d) { printf("CFI_cdesc_t.type =3D %s\n", get_type(d->type)); } =3D=3D> class.F90 <=3D=3D module m type :: t integer :: i double precision :: d integer :: j(10) real :: r(100) real, allocatable :: z(:) end type t interface subroutine foo(t) bind(C) implicit none type(*), dimension(..) :: t end subroutine foo end interface end module m program main use m implicit none type(t) :: x call foo(x) end program main % gfortran-12 -v Using built-in specs. COLLECT_GCC=3Dgfortran-12 COLLECT_LTO_WRAPPER=3D/opt/homebrew/Cellar/gcc/12.2.0/bin/../libexec/gcc/aa= rch64-apple-darwin21/12/lto-wrapper Target: aarch64-apple-darwin21 Configured with: ../configure --prefix=3D/opt/homebrew/opt/gcc --libdir=3D/opt/homebrew/opt/gcc/lib/gcc/current --disable-nls --enable-checking=3Drelease --with-gcc-major-version-only --enable-languages=3Dc,c++,objc,obj-c++,fortran --program-suffix=3D-12 --with-gmp=3D/opt/homebrew/opt/gmp --with-mpfr=3D/opt/homebrew/opt/mpfr --with-mpc=3D/opt/homebrew/opt/libmpc --with-isl=3D/opt/homebrew/opt/isl --with-zstd=3D/opt/homebrew/opt/zstd --with-pkgversion=3D'Homebrew GCC 12.2= .0' --with-bugurl=3Dhttps://github.com/Homebrew/homebrew-core/issues --with-system-zlib --build=3Daarch64-apple-darwin21 --with-sysroot=3D/Library/Developer/CommandLineTools/SDKs/MacOSX12.sdk Thread model: posix Supported LTO compression algorithms: zlib zstd gcc version 12.2.0 (Homebrew GCC 12.2.0)=