http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59213

            Bug ID: 59213
           Summary: Implicit move constructor created when base class has
                    no move constructor
           Product: gcc
           Version: 4.8.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: bmerry at gmail dot com

Created attachment 31258
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=31258&action=edit
Sample case

GCC is accepting the attached code, when it should be rejecting it. That's
assuming I've correctly interpreted the C++11 spec [the draft - N3242].

Class A has no move constructor because it has a user-declared destructor
[12.8.10], and it is not trivially copyable because it has a virtual member
function [12.8.13]. Thus, B's move constructor is implicitly deleted [last
bullet of 12.8.12].

Class C is a movable but non-copyable class. Thus, B's copy constructor is
implicitly deleted [2nd bullet of 12.8.12].

Since B's copy and move constructors are deleted, the expression "return B()"
should be a compilation error.

The Clang 3.4 snapshot shipped with Ubuntu 13.10 rejects the code. It also
rejects the code even if A's destructor is made non-virtual, in which case A is
trivially copyable. I think this might be a Clang bug but I may have missed
something.

Compilation command:
$ g++ -Wall -std=c++11 -c move.cpp 

Build information:
$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/4.8/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu/Linaro
4.8.1-10ubuntu8' --with-bugurl=file:///usr/share/doc/gcc-4.8/README.Bugs
--enable-languages=c,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr
--program-suffix=-4.8 --enable-shared --enable-linker-build-id
--libexecdir=/usr/lib --without-included-gettext --enable-threads=posix
--with-gxx-include-dir=/usr/include/c++/4.8 --libdir=/usr/lib --enable-nls
--with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug
--enable-libstdcxx-time=yes --enable-gnu-unique-object --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-4.8-amd64/jre
--enable-java-home --with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-4.8-amd64
--with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-4.8-amd64
--with-arch-directory=amd64 --with-ecj-jar=/usr/share/java/eclipse-ecj.jar
--enable-objc-gc --enable-multiarch --disable-werror --with-arch-32=i686
--with-abi=m64 --with-multilib-list=m32,m64,mx32 --with-tune=generic
--enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu
--target=x86_64-linux-gnu
Thread model: posix
gcc version 4.8.1 (Ubuntu/Linaro 4.8.1-10ubuntu8) 
b

Reply via email to