From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 7187E3857020; Wed, 2 Jun 2021 07:51:13 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7187E3857020 From: "ehlert at thch dot uni-bonn.de" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/100870] New: Constant expression for bind(C) name in interface body not importable Date: Wed, 02 Jun 2021 07:51:13 +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: 10.2.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: ehlert at thch dot uni-bonn.de 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 attachments.created 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 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 Jun 2021 07:51:13 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D100870 Bug ID: 100870 Summary: Constant expression for bind(C) name in interface body not importable Product: gcc Version: 10.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: fortran Assignee: unassigned at gcc dot gnu.org Reporter: ehlert at thch dot uni-bonn.de Target Milestone: --- Created attachment 50906 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=3D50906&action=3Dedit Minimal reproducer Following example fails to compile with GFortran 10.2.0. The example was checked with Intel's and NAG's Fortran compiler, which both accept the usag= e of constant expressions imported into an interface body as valid Fortran code. >>From the Fortran standard this usage is valid Fortran 2003. Code example to trigger the bug (also in os.f90 attachment): module m_os use, intrinsic :: iso_c_binding implicit none character(len=3D*), parameter :: chdir_symbol =3D "chdir" interface function chdir(path) result(stat) bind(C, name=3Dchdir_symbol) import :: c_char, c_int, chdir_symbol character(kind=3Dc_char, len=3D1), intent(in) :: path(*) integer(c_int) :: stat end function chdir end interface end module m_os Output showing GFortran rejecting this code with an error =E2=9D=AF gfortran -v -save-temps -Wall -Wextra -fno-strict-aliasing -fwrap= v -c os.f90 Using built-in specs. COLLECT_GCC=3Dgfortran Target: x86_64-pc-linux-gnu Configured with: /build/gcc/src/gcc/configure --prefix=3D/usr --libdir=3D/u= sr/lib --libexecdir=3D/usr/lib --mandir=3D/usr/share/man --infodir=3D/usr/share/in= fo --with-bugurl=3Dhttps://bugs.archlinux.org/ --enable-languages=3Dc,c++,ada,fortran,go,lto,objc,obj-c++,d --with-isl --with-linker-hash-style=3Dgnu --with-system-zlib --enable-__cxa_atexit --enable-cet=3Dauto --enable-checking=3Drelease --enable-clocale=3Dgnu --enable-default-pie --enable-default-ssp --enable-gnu-indirect-function --enable-gnu-unique-object --enable-install-libiberty --enable-linker-build= -id --enable-lto --enable-multilib --enable-plugin --enable-shared --enable-threads=3Dposix --disable-libssp --disable-libstdcxx-pch --disable-libunwind-exceptions --disable-werror gdc_include_dir=3D/usr/include/dlang/gdc Thread model: posix Supported LTO compression algorithms: zlib zstd gcc version 10.2.0 (GCC)=20 COLLECT_GCC_OPTIONS=3D'-v' '-save-temps' '-Wall' '-Wextra' '-fno-strict-ali= asing' '-fwrapv' '-c' '-mtune=3Dgeneric' '-march=3Dx86-64' /usr/lib/gcc/x86_64-pc-linux-gnu/10.2.0/f951 os.f90 -quiet -dumpbase os.f90 -mtune=3Dgeneric -march=3Dx86-64 -auxbase os -Wall -Wextra -version -fno-strict-aliasing -fwrapv -fintrinsic-modules-path /usr/lib/gcc/x86_64-pc-linux-gnu/10.2.0/finclude -fpre-include=3D/usr/include/finclude/math-vector-fortran.h -o os.s GNU Fortran (GCC) version 10.2.0 (x86_64-pc-linux-gnu) compiled by GNU C version 10.2.0, GMP version 6.2.1, MPFR version 4.1.0, MPC version 1.2.1, isl version isl-0.21-GMP GGC heuristics: --param ggc-min-expand=3D100 --param ggc-min-heapsize=3D131= 072 GNU Fortran2008 (GCC) version 10.2.0 (x86_64-pc-linux-gnu) compiled by GNU C version 10.2.0, GMP version 6.2.1, MPFR version 4.1.0, MPC version 1.2.1, isl version isl-0.21-GMP GGC heuristics: --param ggc-min-expand=3D100 --param ggc-min-heapsize=3D131= 072 os.f90:7:51: 7 | function chdir(path) result(stat) bind(C, name=3Dchdir_symbol) | 1 Error: Parameter =E2=80=98chdir_symbol=E2=80=99 at (1) has not been declare= d or is a variable, which does not reduce to a constant expression os.f90:8:13: 8 | import :: c_char, c_int, chdir_symbol | 1 Error: IMPORT statement at (1) only permitted in an INTERFACE body os.f90:9:21: 9 | character(kind=3Dc_char, len=3D1), intent(in) :: path(*) | 1 Error: Parameter =E2=80=98c_char=E2=80=99 at (1) has not been declared or i= s a variable, which does not reduce to a constant expression os.f90:10:14: 10 | integer(c_int) :: stat | 1 Error: Parameter =E2=80=98c_int=E2=80=99 at (1) has not been declared or is= a variable, which does not reduce to a constant expression os.f90:11:7: 11 | end function chdir | 1 Error: Expecting END INTERFACE statement at (1)=