[Bug c++/66602] New: std::tuple bug when constructed with temporary empty object

2015-06-19 Thread so61pi.re at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66602

Bug ID: 66602
   Summary: std::tuple bug when constructed with temporary empty
object
   Product: gcc
   Version: unknown
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: so61pi.re at gmail dot com
  Target Milestone: ---

-
#include 
#include 

class empty_t {
};

int main() {
// should print 1, but doesn't
std::tuple a(empty_t{}, 1);
std::cout << std::get<1>(a) << "\n";


// works fine, prints 1
std::tuple b(1, empty_t{});
std::cout << std::get<0>(b) << "\n";


// works fine, prints 1
auto c = std::make_tuple(empty_t{}, 1);
std::cout << std::get<1>(c) << "\n";
}
-

This code works fine when compiled with MSVC or clang.


[Bug c++/66602] std::tuple bug when constructed with temporary empty object

2015-06-19 Thread so61pi.re at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66602

--- Comment #3 from so61pi.re at gmail dot com ---
My current version of GCC is 5.1.0 on Windows, but I also tested on Linux with
same GCC version, and it produced the same bug, which printed random value like
Daniel Krügler have showed.

Apparently, this bug is fixed in gcc HEAD 6.0.0 20150619 (experimental).


My command line was:

g++ -std=c++14 main.cpp -o main.exe


And here is the output of 'g++ -v' on my system:

Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=d:/tools/mingw/bin/../libexec/gcc/x86_64-w64-mingw32/5.1.0/l
to-wrapper.exe
Target: x86_64-w64-mingw32
Configured with: ../src/configure --with-gmp=/c/temp/gcc/gmp
--with-mpfr=/c/temp/gcc/mpfr --with-mpc=/c/temp/gcc/mpc
--enable-languages=c,c++ --build=x86_64-w64-mingw32 --host=x86_64-w64-mingw32
--target=x86_64-w64-mingw32 --disable-multilib --prefix=/c/temp/gcc/dest
--with-sysroot=/c/temp/gcc/dest --disable-libstdcxx-pch --disable-nls
--disable-shared --disable-win32-registry --enable-checking=release
--with-tune=haswell
Thread model: win32
gcc version 5.1.0 (GCC)