From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 934363855034; Mon, 12 Jul 2021 08:22:42 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 934363855034 From: "federico.reghenzani at polimi dot it" To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/101427] New: std::get should refuse to compile if type is provided and it is duplicated in std::tuple Date: Mon, 12 Jul 2021 08:22:42 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: libstdc++ X-Bugzilla-Version: 11.1.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: federico.reghenzani at polimi dot it 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 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, 12 Jul 2021 08:22:42 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D101427 Bug ID: 101427 Summary: std::get should refuse to compile if type is provided and it is duplicated in std::tuple Product: gcc Version: 11.1.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: libstdc++ Assignee: unassigned at gcc dot gnu.org Reporter: federico.reghenzani at polimi dot it Target Milestone: --- The following code should not compile: ---------------------------------------------------------- #include int main() { std::tuple my_record; std::get(my_record) =3D 10; return 0; } ---------------------------------------------------------- Because `std::get` accesses the `int` element which is duplicated. Thi= s is not allowed by the standard: http://eel.is/c++draft/tuple#elem-5 Instead, it compiles and modifies only the first element in GCC 11.1.0 (whi= le it doesn't compile in 10.x.x). A full example here: https://godbolt.org/z/YzorM9P8K Expected behavior ----------------- It should not compile and generate a compilation error. Actual behavior --------------- It compiles and (seems to) modify the first item of the tuple. GCC Information --------------- Using built-in specs. COLLECT_GCC=3Dg++ COLLECT_LTO_WRAPPER=3D/usr/lib/gcc/x86_64-pc-linux-gnu/11.1.0/lto-wrapper 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 11.1.0 (GCC)=