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

            Bug ID: 70472
           Summary: is_copy_constructible<vector<unique_ptr<int>>>::value
                    is true
           Product: gcc
           Version: 6.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: safinaskar at mail dot ru
  Target Milestone: ---

Consider this code:

#include <type_traits>
#include <vector>
#include <memory>
#include <iostream>

int
main (void)
{
  std::cout <<
std::is_copy_constructible<std::vector<std::unique_ptr<int>>>::value << "\n";
}

It gives 1. But, of course, it should give 0, because the following code
doesn't compile:

#include <vector>
#include <memory>

int
main (void)
{
  typedef std::vector<std::unique_ptr<int>> v;
  v a;
  v b = a;
}

I think this problem is solvable. For example, it is solved for
std::exprimental::optional in gcc 6.0.0's stdlibc++.
std::is_copy_constructible<std::experimental::optional<std::unique_ptr<int>>>::value
is false.

Also, please, make sure that std::is_copy_constructible gives right answers for
all standard containers. And same for other type_traits (move_constructible
etc).

I don't know is
std::is_copy_constructible<std::vector<std::unique_ptr<int>>>::value == false
required by the standard. If no, then, please, add this requirement to it.

I noticed this bug when I tried to implement my own class template similar to
std::experimental::optional. Compiler give big error message when I combine my
class with other standard containers. If I add noexcept to my move constructor,
then the error message disappears. So I think this bug somehow related to bug
55043 (bug #55043). If you want, I can describe this my class template in
detail. Also, this bug is very similar to this comment:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=55043#c15 .

I use gcc-snapshot Debian package. Package version is 20160320-1. Output of
"/usr/lib/gcc-snapshot/bin/gcc -v":
COLLECT_GCC=/usr/lib/gcc-snapshot/bin/gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc-snapshot/libexec/gcc/x86_64-linux-gnu/6.0.0/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Debian 20160320-1'
--with-bugurl=file:///usr/share/doc/gcc-snapshot/README.Bugs
--enable-languages=c,ada,c++,java,go,fortran,objc,obj-c++
--prefix=/usr/lib/gcc-snapshot --enable-shared --enable-linker-build-id
--disable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug
--enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new
--enable-gnu-unique-object --disable-vtable-verify --enable-libmpx
--enable-plugin --with-system-zlib --disable-browser-plugin
--enable-java-awt=gtk --enable-gtk-cairo
--with-java-home=/usr/lib/jvm/java-1.5.0-gcj-6-snap-amd64/jre
--enable-java-home --with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-6-snap-amd64
--with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-6-snap-amd64
--with-arch-directory=amd64 --with-ecj-jar=/usr/share/java/eclipse-ecj.jar
--enable-objc-gc --enable-multiarch --with-arch-32=i586 --with-abi=m64
--with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic
--disable-werror --enable-checking=yes --build=x86_64-linux-gnu
--host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 6.0.0 20160320 (experimental) [trunk revision 234355] (Debian
20160320-1)

I use stdlibc++ shipped with this gcc.

Reply via email to