http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56889
Bug #: 56889 Summary: =delete(ing) default copy and move operations for a polymorphic type gives compilation error messages Classification: Unclassified Product: gcc Version: 4.8.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassig...@gcc.gnu.org ReportedBy: amalispe...@yahoo.com Created attachment 29834 --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=29834 smalltestfile when I add Stack(const Stack&)=delete; Stack& operator=(const Stack&)=delete; //no move operations Stack(Stack&&)=delete; Stack& operator=(Stack&&)=delete; to the stack polymorphic type in the attached file, the compiler gives error messages. But if I don't add these methods, as Bjarne Stroutstrup's programming language fourth edition-third chapter draft copy- says, 'In case you forgot to delete a copy or move operation, no harm is done. A move operation is not implicitly generated for a class where the user has explicitly declared a destructor. Furthermore, the generation of copy operations are deprecated in this case (§42.2.3). This can be a good reason to explicitly define a destructor even where the compiler would have implicitly provided one (§17.2.3). The C++ Programming Language, 4th edition ©2012 by Pearson Education, Inc. Reproduced in draft form with the permission of the publisher.', my program gives nomore compiler error messages, and it works as I expect it to. However, I think the compiler should allow me to specify the copy and move methods as =delete in the Stack polymorphic type. -------------- Build: Debug in TestforError --------------- x86_64-w64-mingw32-g++.exe -Wall -fexceptions -g -std=c++0x -Wextra -Wall -v -save-temps -fno-strict-aliasing -fwrapv -c "C:\Users\Pugazhendhi Albert\Desktop\Amali\TestforError\main.cpp" -o obj\Debug\main.o Using built-in specs. COLLECT_GCC=x86_64-w64-mingw32-g++.exe Target: x86_64-w64-mingw32 Configured with: ../../../src/gcc-4.8.0/configure --host=x86_64-w64-mingw32 --build=x86_64-w64-mingw32 --target=x86_64-w64-mingw32 --prefix=/mingw64 --with-sysroot=/temp/x64-480-win32-seh-r1/mingw64 --enable-shared --enable-static --disable-multilib --enable-languages=c,c++,fortran,lto --enable-libstdcxx-time=yes --enable-threads=win32 --enable-libgomp --enable-lto --enable-graphite --enable-checking=release --enable-fully-dynamic-string --enable-version-specific-runtime-libs --disable-isl-version-check --disable-cloog-version-check --disable-libstdcxx-pch --disable-libstdcxx-debug --disable-bootstrap --disable-rpath --disable-win32-registry --disable-nls --disable-werror --disable-symvers --with-gnu-as --with-gnu-ld --with-arch=nocona --with-tune=core2 --with-host-libstdcxx='-static -lstdc++' --with-libiconv --with-system-zlib --with-gmp=/temp/mingw-prereq/x86_64-w64-mingw32-static --with-mpfr=/temp/mingw-prereq/x86_64-w64-mingw32-static --with-mpc=/temp/mingw-prereq/x86_64-w64-mingw32-static --with-isl=/temp/mingw-prereq/x86_64-w64-mingw32-static --with-cloog=/temp/mingw-prereq/x86_64-w64-mingw32-static --enable-cloog-backend=isl --with-pkgversion='rev1, Built by MinGW-builds project' --with-bugurl=http://sourceforge.net/projects/mingwbuilds/ CFLAGS='-O2 -pipe -I/temp/x64-480-win32-seh-r1/libs/include -I/temp/mingw-prereq/x64-zlib/include -I/temp/mingw-prereq/x86_64-w64-mingw32-static/include' CXXFLAGS='-O2 -pipe -I/temp/x64-480-win32-seh-r1/libs/include -I/temp/mingw-prereq/x64-zlib/include -I/temp/mingw-prereq/x86_64-w64-mingw32-static/include' CPPFLAGS= LDFLAGS='-pipe -L/temp/x64-480-win32-seh-r1/libs/lib -L/temp/mingw-prereq/x64-zlib/lib -L/temp/mingw-prereq/x86_64-w64-mingw32-static/lib -L/temp/x64-480-win32-seh-r1/mingw64/opt/lib' Thread model: win32 gcc version 4.8.0 (rev1, Built by MinGW-builds project) COLLECT_GCC_OPTIONS='-fexceptions' '-g' '-std=c++11' '-Wextra' '-Wall' '-v' '-save-temps' '-fno-strict-aliasing' '-fwrapv' '-c' '-o' 'obj\Debug\main.o' '-shared-libgcc' '-mtune=core2' '-march=nocona' c:/amali/x64-4.8.0-release-win32-seh-rev1/mingw64/bin/../libexec/gcc/x86_64-w64-mingw32/4.8.0/cc1plus.exe -E -quiet -v -iprefix c:\amali\x64-4.8.0-release-win32-seh-rev1\mingw64\bin\../lib/gcc/x86_64-w64-mingw32/4.8.0/ -U_REENTRANT C:\Users\Pugazhendhi Albert\Desktop\Amali\TestforError\main.cpp -mtune=core2 -march=nocona -std=c++11 -Wextra -Wall -fexceptions -fno-strict-aliasing -fwrapv -g -fworking-directory -fpch-preprocess -o main.ii ignoring duplicate directory "c:/amali/x64-4.8.0-release-win32-seh-rev1/mingw64/lib/gcc/../../lib/gcc/x86_64-w64-mingw32/4.8.0/include/c++" ignoring duplicate directory "c:/amali/x64-4.8.0-release-win32-seh-rev1/mingw64/lib/gcc/../../lib/gcc/x86_64-w64-mingw32/4.8.0/include/c++/x86_64-w64-mingw32" ignoring duplicate directory "c:/amali/x64-4.8.0-release-win32-seh-rev1/mingw64/lib/gcc/../../lib/gcc/x86_64-w64-mingw32/4.8.0/include/c++/backward" ignoring duplicate directory "c:/amali/x64-4.8.0-release-win32-seh-rev1/mingw64/lib/gcc/../../lib/gcc/x86_64-w64-mingw32/4.8.0/include" ignoring nonexistent directory "C:/gccbuild/msys/temp/x64-480-win32-seh-r1/mingw64C:/gccbuild/msys/mingw64/lib/gcc/x86_64-w64-mingw32/4.8.0/../../../../include" ignoring duplicate directory "c:/amali/x64-4.8.0-release-win32-seh-rev1/mingw64/lib/gcc/../../lib/gcc/x86_64-w64-mingw32/4.8.0/include-fixed" ignoring duplicate directory "c:/amali/x64-4.8.0-release-win32-seh-rev1/mingw64/lib/gcc/../../lib/gcc/x86_64-w64-mingw32/4.8.0/../../../../x86_64-w64-mingw32/include" ignoring nonexistent directory "C:/gccbuild/msys/temp/x64-480-win32-seh-r1/mingw64/mingw/include" #include "..." search starts here: #include <...> search starts here: c:\amali\x64-4.8.0-release-win32-seh-rev1\mingw64\bin\../lib/gcc/x86_64-w64-mingw32/4.8.0/include/c++ c:\amali\x64-4.8.0-release-win32-seh-rev1\mingw64\bin\../lib/gcc/x86_64-w64-mingw32/4.8.0/include/c++/x86_64-w64-mingw32 c:\amali\x64-4.8.0-release-win32-seh-rev1\mingw64\bin\../lib/gcc/x86_64-w64-mingw32/4.8.0/include/c++/backward c:\amali\x64-4.8.0-release-win32-seh-rev1\mingw64\bin\../lib/gcc/x86_64-w64-mingw32/4.8.0/include c:\amali\x64-4.8.0-release-win32-seh-rev1\mingw64\bin\../lib/gcc/x86_64-w64-mingw32/4.8.0/include-fixed c:\amali\x64-4.8.0-release-win32-seh-rev1\mingw64\bin\../lib/gcc/x86_64-w64-mingw32/4.8.0/../../../../x86_64-w64-mingw32/include End of search list. COLLECT_GCC_OPTIONS='-fexceptions' '-g' '-std=c++11' '-Wextra' '-Wall' '-v' '-save-temps' '-fno-strict-aliasing' '-fwrapv' '-c' '-o' 'obj\Debug\main.o' '-shared-libgcc' '-mtune=core2' '-march=nocona' c:/amali/x64-4.8.0-release-win32-seh-rev1/mingw64/bin/../libexec/gcc/x86_64-w64-mingw32/4.8.0/cc1plus.exe -fpreprocessed main.ii -quiet -dumpbase main.cpp -mtune=core2 -march=nocona -auxbase-strip obj\Debug\main.o -g -Wextra -Wall -std=c++11 -version -fexceptions -fno-strict-aliasing -fwrapv -o main.s GNU C++ (rev1, Built by MinGW-builds project) version 4.8.0 (x86_64-w64-mingw32) compiled by GNU C version 4.7.2, GMP version 5.1.1, MPFR version 3.1.2, MPC version 1.0.1 GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072 GNU C++ (rev1, Built by MinGW-builds project) version 4.8.0 (x86_64-w64-mingw32) compiled by GNU C version 4.7.2, GMP version 5.1.1, MPFR version 3.1.2, MPC version 1.0.1 GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072 Compiler executable checksum: 198a59f18ac22b34b3ce85756ec21810 C:\Users\Pugazhendhi Albert\Desktop\Amali\TestforError\main.cpp: In function 'void StackAbst::constanduse()': C:\Users\Pugazhendhi Albert\Desktop\Amali\TestforError\main.cpp:92:46: error: use of deleted function 'StackAbst::vector_stack<int>::vector_stack(std::initializer_list<int>)' vector_stack<int> vst{1,2,3,4,5,6,7,8,9,10}; ^ C:\Users\Pugazhendhi Albert\Desktop\Amali\TestforError\main.cpp:39:19: note: 'StackAbst::vector_stack<int>::vector_stack(std::initializer_list<int>)' is implicitly deleted because the default definition would be ill-formed: using Base::Base; ^ C:\Users\Pugazhendhi Albert\Desktop\Amali\TestforError\main.cpp:39:19: error: no matching function for call to 'StackAbst::Stack<int>::Stack()' C:\Users\Pugazhendhi Albert\Desktop\Amali\TestforError\main.cpp:39:19: note: candidates are: C:\Users\Pugazhendhi Albert\Desktop\Amali\TestforError\main.cpp:19:4: note: StackAbst::Stack<T>::Stack(StackAbst::Stack<T>&&) [with T = int] <deleted> Stack(Stack&&)=delete; ^ C:\Users\Pugazhendhi Albert\Desktop\Amali\TestforError\main.cpp:19:4: note: candidate expects 1 argument, 0 provided C:\Users\Pugazhendhi Albert\Desktop\Amali\TestforError\main.cpp:16:4: note: StackAbst::Stack<T>::Stack(const StackAbst::Stack<T>&) [with T = int] <deleted> Stack(const Stack&)=delete; ^ C:\Users\Pugazhendhi Albert\Desktop\Amali\TestforError\main.cpp:16:4: note: candidate expects 1 argument, 0 provided C:\Users\Pugazhendhi Albert\Desktop\Amali\TestforError\main.cpp: In instantiation of 'StackAbst::vector_stack<T>* StackAbst::vector_stack<T>::clone() const [with T = int]': C:\Users\Pugazhendhi Albert\Desktop\Amali\TestforError\main.cpp:102:1: required from here C:\Users\Pugazhendhi Albert\Desktop\Amali\TestforError\main.cpp:43:39: error: use of deleted function 'StackAbst::vector_stack<int>::vector_stack(const StackAbst::vector_stack<int>&)' return new vector_stack(*this); // using copy constructor ^ C:\Users\Pugazhendhi Albert\Desktop\Amali\TestforError\main.cpp:32:7: note: 'StackAbst::vector_stack<int>::vector_stack(const StackAbst::vector_stack<int>&)' is implicitly deleted because the default definition would be ill-formed: class vector_stack : public Stack<T>, private std::vector<T>{ ^ C:\Users\Pugazhendhi Albert\Desktop\Amali\TestforError\main.cpp:32:7: error: use of deleted function 'StackAbst::Stack<T>::Stack(const StackAbst::Stack<T>&) [with T = int]' C:\Users\Pugazhendhi Albert\Desktop\Amali\TestforError\main.cpp:16:4: error: declared here Stack(const Stack&)=delete; ^ Process terminated with status 1 (0 minutes, 0 seconds) 13 errors, 0 warnings