public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/59213] New: Implicit move constructor created when base class has no move constructor
@ 2013-11-20 13:33 bmerry at gmail dot com
  2013-11-20 13:47 ` [Bug c++/59213] " redi at gcc dot gnu.org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: bmerry at gmail dot com @ 2013-11-20 13:33 UTC (permalink / raw)
  To: gcc-bugs

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


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

* [Bug c++/59213] Implicit move constructor created when base class has no move constructor
  2013-11-20 13:33 [Bug c++/59213] New: Implicit move constructor created when base class has no move constructor bmerry at gmail dot com
@ 2013-11-20 13:47 ` redi at gcc dot gnu.org
  2013-11-20 13:49 ` redi at gcc dot gnu.org
  2013-11-20 13:56 ` bmerry at gmail dot com
  2 siblings, 0 replies; 4+ messages in thread
From: redi at gcc dot gnu.org @ 2013-11-20 13:47 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
I think G++ is implementing the resolution of
http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#1402


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

* [Bug c++/59213] Implicit move constructor created when base class has no move constructor
  2013-11-20 13:33 [Bug c++/59213] New: Implicit move constructor created when base class has no move constructor bmerry at gmail dot com
  2013-11-20 13:47 ` [Bug c++/59213] " redi at gcc dot gnu.org
@ 2013-11-20 13:49 ` redi at gcc dot gnu.org
  2013-11-20 13:56 ` bmerry at gmail dot com
  2 siblings, 0 replies; 4+ messages in thread
From: redi at gcc dot gnu.org @ 2013-11-20 13:49 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Bruce Merry from comment #0)
> assuming I've correctly interpreted the C++11 spec [the draft - N3242].

That's a pretty old draft now, you'd be better looking at a current draft
(N3797) not one that is older than the C++11 standard.


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

* [Bug c++/59213] Implicit move constructor created when base class has no move constructor
  2013-11-20 13:33 [Bug c++/59213] New: Implicit move constructor created when base class has no move constructor bmerry at gmail dot com
  2013-11-20 13:47 ` [Bug c++/59213] " redi at gcc dot gnu.org
  2013-11-20 13:49 ` redi at gcc dot gnu.org
@ 2013-11-20 13:56 ` bmerry at gmail dot com
  2 siblings, 0 replies; 4+ messages in thread
From: bmerry at gmail dot com @ 2013-11-20 13:56 UTC (permalink / raw)
  To: gcc-bugs

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

Bruce Merry <bmerry at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|---                         |INVALID

--- Comment #3 from Bruce Merry <bmerry at gmail dot com> ---
(In reply to Jonathan Wakely from comment #1)
> I think G++ is implementing the resolution of
> http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#1402

Thanks, I wasn't aware of this. With the changes in the December 2012
resolution listed there, GCC does seem to be behaving correctly. I'll mark this
bug as invalid and update the Clang bug I filed
(http://llvm.org/bugs/show_bug.cgi?id=18005).


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

end of thread, other threads:[~2013-11-20 13:56 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-11-20 13:33 [Bug c++/59213] New: Implicit move constructor created when base class has no move constructor bmerry at gmail dot com
2013-11-20 13:47 ` [Bug c++/59213] " redi at gcc dot gnu.org
2013-11-20 13:49 ` redi at gcc dot gnu.org
2013-11-20 13:56 ` bmerry at gmail dot com

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).