public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/101427] New: std::get should refuse to compile if type is provided and it is duplicated in std::tuple
@ 2021-07-12  8:22 federico.reghenzani at polimi dot it
  2021-07-12 10:37 ` [Bug libstdc++/101427] [11/12 Regression] " redi at gcc dot gnu.org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: federico.reghenzani at polimi dot it @ 2021-07-12  8:22 UTC (permalink / raw)
  To: gcc-bugs

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

            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 <tuple>

int main() {

        std::tuple<int, int> my_record;
        std::get<int>(my_record) = 10;

        return 0;
}
----------------------------------------------------------

Because `std::get<int>` accesses the `int` element which is duplicated. This 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 (while
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=g++
COLLECT_LTO_WRAPPER=/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=/usr --libdir=/usr/lib
--libexecdir=/usr/lib --mandir=/usr/share/man --infodir=/usr/share/info
--with-bugurl=https://bugs.archlinux.org/
--enable-languages=c,c++,ada,fortran,go,lto,objc,obj-c++,d --with-isl
--with-linker-hash-style=gnu --with-system-zlib --enable-__cxa_atexit
--enable-cet=auto --enable-checking=release --enable-clocale=gnu
--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=posix --disable-libssp --disable-libstdcxx-pch
--disable-libunwind-exceptions --disable-werror
gdc_include_dir=/usr/include/dlang/gdc
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 11.1.0 (GCC)

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2021-07-19 13:09 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-12  8:22 [Bug libstdc++/101427] New: std::get should refuse to compile if type is provided and it is duplicated in std::tuple federico.reghenzani at polimi dot it
2021-07-12 10:37 ` [Bug libstdc++/101427] [11/12 Regression] " redi at gcc dot gnu.org
2021-07-15 13:14 ` redi at gcc dot gnu.org
2021-07-15 15:26 ` cvs-commit at gcc dot gnu.org
2021-07-15 15:32 ` [Bug libstdc++/101427] [11 " redi at gcc dot gnu.org
2021-07-19 12:38 ` cvs-commit at gcc dot gnu.org
2021-07-19 13:09 ` redi at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).