From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id AF01D386188D; Mon, 1 Feb 2021 16:15:19 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org AF01D386188D From: "stephan.oostveen@nextlevel-electronics.com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/98919] New: auto declaration of multiple variables allows inconsistent types Date: Mon, 01 Feb 2021 16:15:19 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 10.2.1 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: stephan.oostveen@nextlevel-electronics.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 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: Mon, 01 Feb 2021 16:15:19 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D98919 Bug ID: 98919 Summary: auto declaration of multiple variables allows inconsistent types Product: gcc Version: 10.2.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: stephan.oostveen@nextlevel-electronics.com Target Milestone: --- Created attachment 50111 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=3D50111&action=3Dedit Preprocessed file gcc version: 10.2.1 20201125 (Red Hat 10.2.1-9) (GCC) System version: Fedora 33 x86_64 Compile command: gcc -v -save-temps -std=3Dc++17 -O3 -Wall -Wextra -Wpedant= ic -o test test.cpp auto allows to declare two different types in a single statement when used = in a templated context. See also https://godbolt.org/z/brWYjP as an example. Compiler output: Using built-in specs. COLLECT_GCC=3Dgcc COLLECT_LTO_WRAPPER=3D/usr/libexec/gcc/x86_64-redhat-linux/10/lto-wrapper OFFLOAD_TARGET_NAMES=3Dnvptx-none OFFLOAD_TARGET_DEFAULT=3D1 Target: x86_64-redhat-linux Configured with: ../configure --enable-bootstrap --enable-languages=3Dc,c++,fortran,objc,obj-c++,ada,go,d,lto --prefix=3D/usr --mandir=3D/usr/share/man --infodir=3D/usr/share/info --with-bugurl=3Dhttp://bugzilla.redhat.com/bugzilla --enable-shared --enable-threads=3Dposix --enable-checking=3Drelease --enable-multilib --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-gcc-major-version-only --with-linker-hash-style=3Dgnu --enable-plugin --enable-initfini-array --with-isl --enable-offload-targets=3Dnvptx-none --without-cuda-driver --enable-gnu-indirect-function --enable-cet --with-tune=3Dgeneric --with-arch_32=3Di686 --build=3Dx86_64-redhat-linux Thread model: posix Supported LTO compression algorithms: zlib zstd gcc version 10.2.1 20201125 (Red Hat 10.2.1-9) (GCC)=20 COLLECT_GCC_OPTIONS=3D'-v' '-save-temps' '-std=3Dc++17' '-O3' '-Wall' '-Wex= tra' '-Wpedantic' '-o' 'test' '-mtune=3Dgeneric' '-march=3Dx86-64' /usr/libexec/gcc/x86_64-redhat-linux/10/cc1plus -E -quiet -v -D_GNU_SOURCE test.cpp -mtune=3Dgeneric -march=3Dx86-64 -std=3Dc++17 -Wall -Wextra -Wpeda= ntic -O3 -fpch-preprocess -o test.ii ignoring nonexistent directory "/usr/lib/gcc/x86_64-redhat-linux/10/include-fixed" ignoring nonexistent directory "/usr/lib/gcc/x86_64-redhat-linux/10/../../../../x86_64-redhat-linux/includ= e" #include "..." search starts here: #include <...> search starts here: /usr/lib/gcc/x86_64-redhat-linux/10/../../../../include/c++/10 /usr/lib/gcc/x86_64-redhat-linux/10/../../../../include/c++/10/x86_64-redha= t-linux /usr/lib/gcc/x86_64-redhat-linux/10/../../../../include/c++/10/backward /usr/lib/gcc/x86_64-redhat-linux/10/include /usr/local/include /usr/include End of search list. COLLECT_GCC_OPTIONS=3D'-v' '-save-temps' '-std=3Dc++17' '-O3' '-Wall' '-Wex= tra' '-Wpedantic' '-o' 'test' '-mtune=3Dgeneric' '-march=3Dx86-64' /usr/libexec/gcc/x86_64-redhat-linux/10/cc1plus -fpreprocessed test.ii -qu= iet -dumpbase test.cpp -mtune=3Dgeneric -march=3Dx86-64 -auxbase test -O3 -Wall= -Wextra -Wpedantic -std=3Dc++17 -version -o test.s GNU C++17 (GCC) version 10.2.1 20201125 (Red Hat 10.2.1-9) (x86_64-redhat-linux) compiled by GNU C version 10.2.1 20201125 (Red Hat 10.2.1-9), GMP version 6.2.0, MPFR version 4.1.0, MPC version 1.1.0, isl version isl-0.16.1-GMP GGC heuristics: --param ggc-min-expand=3D100 --param ggc-min-heapsize=3D131= 072 GNU C++17 (GCC) version 10.2.1 20201125 (Red Hat 10.2.1-9) (x86_64-redhat-linux) compiled by GNU C version 10.2.1 20201125 (Red Hat 10.2.1-9), GMP version 6.2.0, MPFR version 4.1.0, MPC version 1.1.0, isl version isl-0.16.1-GMP GGC heuristics: --param ggc-min-expand=3D100 --param ggc-min-heapsize=3D131= 072 Compiler executable checksum: 9e47728dd41983b7aeec830bfccf6d2e test.cpp: In instantiation of =E2=80=98constexpr void test() [with long uns= igned int N =3D 42]=E2=80=99: test.cpp:15:14: required from here test.cpp:11:10: warning: unused variable =E2=80=98aIt=E2=80=99 [-Wunused-va= riable] 11 | auto aIt =3D begin(a), bIt =3D begin(b); | ^~~ test.cpp:11:26: warning: unused variable =E2=80=98bIt=E2=80=99 [-Wunused-va= riable] 11 | auto aIt =3D begin(a), bIt =3D begin(b); | ^~~ COLLECT_GCC_OPTIONS=3D'-v' '-save-temps' '-std=3Dc++17' '-O3' '-Wall' '-Wex= tra' '-Wpedantic' '-o' 'test' '-mtune=3Dgeneric' '-march=3Dx86-64' as -v --64 -o test.o test.s GNU assembler version 2.35 (x86_64-redhat-linux) using BFD version version 2.35-18.fc33 COMPILER_PATH=3D/usr/libexec/gcc/x86_64-redhat-linux/10/:/usr/libexec/gcc/x= 86_64-redhat-linux/10/:/usr/libexec/gcc/x86_64-redhat-linux/:/usr/lib/gcc/x= 86_64-redhat-linux/10/:/usr/lib/gcc/x86_64-redhat-linux/ LIBRARY_PATH=3D/usr/lib/gcc/x86_64-redhat-linux/10/:/usr/lib/gcc/x86_64-red= hat-linux/10/../../../../lib64/:/lib/../lib64/:/usr/lib/../lib64/:/usr/lib/= gcc/x86_64-redhat-linux/10/../../../:/lib/:/usr/lib/ COLLECT_GCC_OPTIONS=3D'-v' '-save-temps' '-std=3Dc++17' '-O3' '-Wall' '-Wex= tra' '-Wpedantic' '-o' 'test' '-mtune=3Dgeneric' '-march=3Dx86-64' /usr/libexec/gcc/x86_64-redhat-linux/10/collect2 -plugin /usr/libexec/gcc/x86_64-redhat-linux/10/liblto_plugin.so -plugin-opt=3D/usr/libexec/gcc/x86_64-redhat-linux/10/lto-wrapper -plugin-opt=3D-fresolution=3Dtest.res -plugin-opt=3D-pass-through=3D-lgcc -plugin-opt=3D-pass-through=3D-lgcc_s -plugin-opt=3D-pass-through=3D-lc -plugin-opt=3D-pass-through=3D-lgcc -plugin-opt=3D-pass-through=3D-lgcc_s -= -build-id --no-add-needed --eh-frame-hdr --hash-style=3Dgnu -m elf_x86_64 -dynamic-li= nker /lib64/ld-linux-x86-64.so.2 -o test /usr/lib/gcc/x86_64-redhat-linux/10/../../../../lib64/crt1.o /usr/lib/gcc/x86_64-redhat-linux/10/../../../../lib64/crti.o /usr/lib/gcc/x86_64-redhat-linux/10/crtbegin.o -L/usr/lib/gcc/x86_64-redhat-linux/10 -L/usr/lib/gcc/x86_64-redhat-linux/10/../../../../lib64 -L/lib/../lib64 -L/usr/lib/../lib64 -L/usr/lib/gcc/x86_64-redhat-linux/10/../../.. test.o -= lgcc --push-state --as-needed -lgcc_s --pop-state -lc -lgcc --push-state --as-ne= eded -lgcc_s --pop-state /usr/lib/gcc/x86_64-redhat-linux/10/crtend.o /usr/lib/gcc/x86_64-redhat-linux/10/../../../../lib64/crtn.o COLLECT_GCC_OPTIONS=3D'-v' '-save-temps' '-std=3Dc++17' '-O3' '-Wall' '-Wex= tra' '-Wpedantic' '-o' 'test' '-mtune=3Dgeneric' '-march=3Dx86-64'=