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

            Bug ID: 119400
           Summary: Windows-targeted builds of GCC allow -fpermissive
                    -Wimplicit-int behaviour in C++
           Product: gcc
           Version: 14.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: atstng at gmail dot com
  Target Milestone: ---

Windows-targeted builds of GCC allow -fpermissive -Wimplicit-int behaviour in
C++ programs. 

Expression in form

<cv-qualifier> &<variable-name> = <value>;

appears to be well-formed and compilable, creating the reference of type int.

Source code of

int main() {
    int v1 = 0;
    const &r1 = v1;
}

compiles successfully with 

g++ main.cpp

without any output on a list of window-targeted distributions of GCC:

MinGW-w64 gcc-14.2.0
MinGW-w64 gcc-11.2.0-llvm-13.0.0-mingw-w64ucrt-9.0.0-r2
Cygwin (x86_64) (latest build for 19 March 2025)
tdm64-gcc-10.3.0-2

Compile options tested:
-std=XXX options have no effect
-fpermissive has no effect
-fno-permissive has no effect
-Wimplicit-int gives the following warning and has no effect

cc1plus.exe: warning: command-line option '-Wimplicit-int' is valid for C/ObjC
but not for C++

Non-Windows versions of GCC give the following error

error: ISO C++ forbids declaration of 'r1' with no type [-fpermissive]

that is reduced to warning with -fpermissive

Exact gcc -v of tested compilers:

D:\cygwin64\bin>"./gcc" -v
Using built-in specs.
COLLECT_GCC=./gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-pc-cygwin/12/lto-wrapper.exe
Target: x86_64-pc-cygwin
Configured with: /mnt/share/cygpkgs/gcc/gcc.x86_64/src/gcc-12.4.0/configure
--srcdir=/mnt/share/cygpkgs/gcc/gcc.x86_64/src/gcc-12.4.0 --prefix=/usr
--exec-prefix=/usr --localstatedir=/var --sysconfdir=/etc
--docdir=/usr/share/doc/gcc --htmldir=/usr/share/doc/gcc/html -C
--build=x86_64-pc-cygwin --host=x86_64-pc-cygwin --target=x86_64-pc-cygwin
--without-libiconv-prefix --without-libintl-prefix --libexecdir=/usr/lib
--with-gcc-major-version-only --enable-shared --enable-shared-libgcc
--enable-static --enable-version-specific-runtime-libs --enable-bootstrap
--enable-__cxa_atexit --enable-clocale=newlib --with-dwarf2 --with-tune=generic
--enable-languages=ada,c,c++,fortran,lto,objc,obj-c++,jit --enable-graphite
--enable-threads=posix --enable-libatomic --enable-libgomp --enable-libquadmath
--enable-libquadmath-support --disable-libssp --enable-libada --disable-symvers
--disable-multilib --with-gnu-ld --with-gnu-as
--with-cloog-include=/usr/include/cloog-isl --without-libiconv-prefix
--without-libintl-prefix --with-system-zlib --enable-linker-build-id
--with-default-libstdcxx-abi=gcc4-compatible --enable-libstdcxx-filesystem-ts
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 12.4.0 (GCC)

D:\mingw_x86_64-14.2.0\mingw64\bin>"./gcc" -v
Using built-in specs.
COLLECT_GCC=./gcc
COLLECT_LTO_WRAPPER=D:/mingw_x86_64-14.2.0/mingw64/bin/../libexec/gcc/x86_64-w64-mingw32/14.2.0/lto-wrapper.exe
Target: x86_64-w64-mingw32
Configured with: ../../../src/gcc-14.2.0/configure --host=x86_64-w64-mingw32
--build=x86_64-w64-mingw32 --target=x86_64-w64-mingw32 --prefix=/mingw64
--with-sysroot=/c/buildroot/x86_64-1420-win32-seh-ucrt-rt_v12-rev2/mingw64
--enable-host-shared --disable-multilib --enable-languages=c,c++,fortran,lto
--enable-libstdcxx-time=yes --enable-threads=win32
--enable-libstdcxx-threads=yes --enable-libgomp --enable-libatomic --enable-lto
--enable-graphite --enable-checking=release --enable-fully-dynamic-string
--enable-version-specific-runtime-libs --enable-libstdcxx-filesystem-ts=yes
--disable-libssp --disable-libstdcxx-pch --disable-libstdcxx-debug
--enable-bootstrap --disable-rpath --disable-win32-registry --disable-nls
--disable-werror --disable-symvers --with-gnu-as --with-gnu-ld
--with-arch=nocona --with-tune=core2 --with-libiconv --with-system-zlib
--with-gmp=/c/buildroot/prerequisites/x86_64-w64-mingw32-static
--with-mpfr=/c/buildroot/prerequisites/x86_64-w64-mingw32-static
--with-mpc=/c/buildroot/prerequisites/x86_64-w64-mingw32-static
--with-isl=/c/buildroot/prerequisites/x86_64-w64-mingw32-static
--with-pkgversion='x86_64-win32-seh-rev2, Built by MinGW-Builds project'
--with-bugurl=https://github.com/niXman/mingw-builds
LD_FOR_TARGET=/c/buildroot/x86_64-1420-win32-seh-ucrt-rt_v12-rev2/mingw64/bin/ld.exe
--with-boot-ldflags='-pipe -fno-ident
-L/c/buildroot/x86_64-1420-win32-seh-ucrt-rt_v12-rev2/mingw64/opt/lib
-L/c/buildroot/prerequisites/x86_64-zlib-static/lib
-L/c/buildroot/prerequisites/x86_64-w64-mingw32-static/lib 
-Wl,--disable-dynamicbase -static-libstdc++ -static-libgcc'
Thread model: win32
Supported LTO compression algorithms: zlib
gcc version 14.2.0 (x86_64-win32-seh-rev2, Built by MinGW-Builds project)

D:\mingw_x86_64-11.2.0\mingw64\bin>"./gcc" -v
Using built-in specs.
COLLECT_GCC=./gcc
COLLECT_LTO_WRAPPER=d:/mingw_x86_64-11.2.0/mingw64/bin/../libexec/gcc/x86_64-w64-mingw32/11.2.0/lto-wrapper.exe
OFFLOAD_TARGET_NAMES=nvptx-none
Target: x86_64-w64-mingw32
Configured with: ../configure
--prefix=/R/winlibs64_stage/inst_gcc-11.2.0/share/gcc
--build=x86_64-w64-mingw32 --host=x86_64-w64-mingw32
--enable-offload-targets=nvptx-none --with-pkgversion='MinGW-W64
x86_64-ucrt-posix-seh, built by Brecht Sanders' --with-tune=generic
--enable-checking=release --enable-threads=posix --disable-sjlj-exceptions
--disable-libunwind-exceptions --disable-serial-configure --disable-bootstrap
--enable-host-shared --enable-plugin --disable-default-ssp --disable-rpath
--enable-libstdcxx-pch --enable-libstdcxx-time=yes --disable-libstdcxx-debug
--disable-version-specific-runtime-libs --with-stabs --disable-symvers
--enable-languages=c,c++,fortran,lto,objc,obj-c++,d,jit --disable-gold
--disable-nls --disable-stage1-checking --disable-win32-registry
--disable-multilib --enable-ld --enable-libquadmath --enable-libada
--enable-libssp --enable-libstdcxx --enable-lto --enable-fully-dynamic-string
--enable-libgomp --enable-graphite --enable-mingw-wildcard
--with-mpc=/d/Prog/winlibs64_stage/custombuilt
--with-mpfr=/d/Prog/winlibs64_stage/custombuilt
--with-gmp=/d/Prog/winlibs64_stage/custombuilt
--with-isl=/d/Prog/winlibs64_stage/custombuilt --enable-install-libiberty
--enable-__cxa_atexit --without-included-gettext --with-diagnostics-color=auto
--enable-clocale=generic --with-libiconv --with-system-zlib
--with-build-sysroot=/R/winlibs64_stage/gcc-11.2.0/build_mingw/mingw-w64
CFLAGS=-I/d/Prog/winlibs64_stage/custombuilt/include/libdl-win32
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 11.2.0 (MinGW-W64 x86_64-ucrt-posix-seh, built by Brecht Sanders)

D:\TDMGCC64\bin>"./gcc" -v
Используются внутренние спецификации.
COLLECT_GCC=./gcc
COLLECT_LTO_WRAPPER=D:/TDMGCC64/bin/../libexec/gcc/x86_64-w64-mingw32/10.3.0/lto-wrapper.exe
Целевая архитектура: x86_64-w64-mingw32
Параметры конфигурации: ../../../src/gcc-git-10.3.0/configure
--build=x86_64-w64-mingw32 --enable-targets=all
--enable-languages=ada,c,c++,fortran,jit,lto,objc,obj-c++ --enable-libgomp
--enable-lto --enable-graphite --enable-cxx-flags=-DWINPTHREAD_STATIC
--disable-build-with-cxx --disable-build-poststage1-with-cxx
--enable-libstdcxx-debug --enable-threads=posix
--enable-version-specific-runtime-libs --enable-fully-dynamic-string
--enable-libstdcxx-filesystem-ts=yes --disable-libstdcxx-pch
--enable-libstdcxx-threads --enable-libstdcxx-time=yes --enable-mingw-wildcard
--with-gnu-ld --disable-werror --enable-nls --disable-win32-registry
--enable-large-address-aware --disable-rpath --disable-symvers
--prefix=/mingw64tdm --with-local-prefix=/mingw64tdm --with-pkgversion=tdm64-1
--with-bugurl=https://github.com/jmeubank/tdm-gcc/issues
Модель многопоточности: posix
Supported LTO compression algorithms: zlib zstd
gcc версия 10.3.0 (tdm64-1)

Reply via email to