public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/56889] New: =delete(ing) default copy and move operations for a polymorphic type gives compilation error messages
@ 2013-04-09 6:02 amalisperid at yahoo dot com
2013-04-09 9:10 ` [Bug c++/56889] " daniel.kruegler at googlemail dot com
` (6 more replies)
0 siblings, 7 replies; 8+ messages in thread
From: amalisperid at yahoo dot com @ 2013-04-09 6:02 UTC (permalink / raw)
To: gcc-bugs
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: unassigned@gcc.gnu.org
ReportedBy: amalisperid@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
>From gcc-bugs-return-419559-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Tue Apr 09 06:15:54 2013
Return-Path: <gcc-bugs-return-419559-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 21709 invoked by alias); 9 Apr 2013 06:15:54 -0000
Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm
Precedence: bulk
List-Id: <gcc-bugs.gcc.gnu.org>
List-Archive: <http://gcc.gnu.org/ml/gcc-bugs/>
List-Post: <mailto:gcc-bugs@gcc.gnu.org>
List-Help: <mailto:gcc-bugs-help@gcc.gnu.org>
Sender: gcc-bugs-owner@gcc.gnu.org
Delivered-To: mailing list gcc-bugs@gcc.gnu.org
Received: (qmail 21665 invoked by uid 48); 9 Apr 2013 06:15:50 -0000
From: "mpolacek at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug rtl-optimization/56885] ICE: in assign_by_spills, at lra-assigns.c:1268 with -O -fschedule-insns -fselective-scheduling
Date: Tue, 09 Apr 2013 06:15:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: rtl-optimization
X-Bugzilla-Keywords: ice-on-valid-code
X-Bugzilla-Severity: normal
X-Bugzilla-Who: mpolacek at gcc dot gnu.org
X-Bugzilla-Status: NEW
X-Bugzilla-Priority: P3
X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org
X-Bugzilla-Target-Milestone: 4.8.1
X-Bugzilla-Changed-Fields: Status Last reconfirmed CC Target Milestone Ever Confirmed
Message-ID: <bug-56885-4-bAjTGfR1oc@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-56885-4@http.gcc.gnu.org/bugzilla/>
References: <bug-56885-4@http.gcc.gnu.org/bugzilla/>
X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/
Auto-Submitted: auto-generated
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
MIME-Version: 1.0
X-SW-Source: 2013-04/txt/msg00704.txt.bz2
Content-length: 1584
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56885
Marek Polacek <mpolacek at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Last reconfirmed| |2013-04-09
CC| |mpolacek at gcc dot
| |gnu.org, vmakarov at gcc
| |dot gnu.org
Target Milestone|--- |4.8.1
Ever Confirmed|0 |1
--- Comment #1 from Marek Polacek <mpolacek at gcc dot gnu.org> 2013-04-09 06:15:49 UTC ---
Confirmed with trunk/4.8, but with 4.6/4.7 I see:
x.c:20:1: error: unable to find a register to spill in class ‘DIREG’
x.c:20:1: error: this is the insn:
(insn 33 36 35 5 (parallel [
(set (reg:DI 2 cx [80])
(const_int 0 [0]))
(set (reg/f:DI 0 ax [78])
(plus:DI (reg/f:DI 1 dx [77])
(reg:DI 2 cx [80])))
(set (mem:BLK (reg/f:DI 1 dx [77]) [0 S15 A8])
(const_int 0 [0]))
(use (reg:QI 6 bp [81]))
(use (reg:DI 2 cx [80]))
]) x.c:16 884 {*rep_stosqi}
(expr_list:REG_DEAD (reg/f:DI 1 dx [77])
(expr_list:REG_UNUSED (reg:DI 2 cx [80])
(expr_list:REG_UNUSED (reg/f:DI 0 ax [78])
(nil)))))
x.c:20: confused by earlier errors, bailing out
>From gcc-bugs-return-419560-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Tue Apr 09 06:29:16 2013
Return-Path: <gcc-bugs-return-419560-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 27571 invoked by alias); 9 Apr 2013 06:29:16 -0000
Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm
Precedence: bulk
List-Id: <gcc-bugs.gcc.gnu.org>
List-Archive: <http://gcc.gnu.org/ml/gcc-bugs/>
List-Post: <mailto:gcc-bugs@gcc.gnu.org>
List-Help: <mailto:gcc-bugs-help@gcc.gnu.org>
Sender: gcc-bugs-owner@gcc.gnu.org
Delivered-To: mailing list gcc-bugs@gcc.gnu.org
Received: (qmail 27539 invoked by uid 48); 9 Apr 2013 06:29:13 -0000
From: "mpolacek at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug rtl-optimization/56885] ICE: in assign_by_spills, at lra-assigns.c:1268 with -O -fschedule-insns -fselective-scheduling
Date: Tue, 09 Apr 2013 06:29:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: rtl-optimization
X-Bugzilla-Keywords: ice-on-valid-code
X-Bugzilla-Severity: normal
X-Bugzilla-Who: mpolacek at gcc dot gnu.org
X-Bugzilla-Status: NEW
X-Bugzilla-Priority: P3
X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org
X-Bugzilla-Target-Milestone: 4.8.1
X-Bugzilla-Changed-Fields:
Message-ID: <bug-56885-4-DECPtYwB2g@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-56885-4@http.gcc.gnu.org/bugzilla/>
References: <bug-56885-4@http.gcc.gnu.org/bugzilla/>
X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/
Auto-Submitted: auto-generated
Content-Type: text/plain; charset="UTF-8"
MIME-Version: 1.0
X-SW-Source: 2013-04/txt/msg00705.txt.bz2
Content-length: 232
http://gcc.gnu.org/bugzilla/show_bug.cgi?idV885
--- Comment #2 from Marek Polacek <mpolacek at gcc dot gnu.org> 2013-04-09 06:29:13 UTC ---
Anyway, started with
http://gcc.gnu.org/viewcvs/gcc?view=revision&revision\x192719
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/56889] =delete(ing) default copy and move operations for a polymorphic type gives compilation error messages
2013-04-09 6:02 [Bug c++/56889] New: =delete(ing) default copy and move operations for a polymorphic type gives compilation error messages amalisperid at yahoo dot com
@ 2013-04-09 9:10 ` daniel.kruegler at googlemail dot com
2013-04-09 9:36 ` daniel.kruegler at googlemail dot com
` (5 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: daniel.kruegler at googlemail dot com @ 2013-04-09 9:10 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56889
Daniel Krügler <daniel.kruegler at googlemail dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |daniel.kruegler at
| |googlemail dot com
--- Comment #1 from Daniel Krügler <daniel.kruegler at googlemail dot com> 2013-04-09 09:10:52 UTC ---
There are several problems in your example:
1) You have not declared a default constructor in template Stack, but you have
provided user-declared constructors (The deleted ones). This has the effect
that the Stack template has a no implicitly declared default constructor, which
again has the effect that the initializer-list constructor generated by the
compiler in vector_stack is deleted, because it would implicitly call the
missing default constructor of Stack. Solution: Add a (defaulted) default
constructor to the Stack template.
2) The clone function in vector_stack would call the copy constructor of that
type. But this one is deleted, because the Stack template has an explicitly
deleted copy constructor. This is a design error.
>From gcc-bugs-return-419572-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Tue Apr 09 09:23:45 2013
Return-Path: <gcc-bugs-return-419572-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 7480 invoked by alias); 9 Apr 2013 09:23:45 -0000
Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm
Precedence: bulk
List-Id: <gcc-bugs.gcc.gnu.org>
List-Archive: <http://gcc.gnu.org/ml/gcc-bugs/>
List-Post: <mailto:gcc-bugs@gcc.gnu.org>
List-Help: <mailto:gcc-bugs-help@gcc.gnu.org>
Sender: gcc-bugs-owner@gcc.gnu.org
Delivered-To: mailing list gcc-bugs@gcc.gnu.org
Received: (qmail 6906 invoked by uid 48); 9 Apr 2013 09:23:41 -0000
From: "jakub at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug middle-end/56883] error openmp parallel for order
Date: Tue, 09 Apr 2013 09:23:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: middle-end
X-Bugzilla-Keywords:
X-Bugzilla-Severity: major
X-Bugzilla-Who: jakub at gcc dot gnu.org
X-Bugzilla-Status: ASSIGNED
X-Bugzilla-Priority: P3
X-Bugzilla-Assigned-To: jakub at gcc dot gnu.org
X-Bugzilla-Target-Milestone: ---
X-Bugzilla-Changed-Fields: Status Component AssignedTo
Message-ID: <bug-56883-4-Dc9lagubCw@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-56883-4@http.gcc.gnu.org/bugzilla/>
References: <bug-56883-4@http.gcc.gnu.org/bugzilla/>
X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/
Auto-Submitted: auto-generated
Content-Type: text/plain; charset="UTF-8"
MIME-Version: 1.0
X-SW-Source: 2013-04/txt/msg00717.txt.bz2
Content-length: 488
http://gcc.gnu.org/bugzilla/show_bug.cgi?idV883
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |ASSIGNED
Component|c++ |middle-end
AssignedTo|unassigned at gcc dot |jakub at gcc dot gnu.org
|gnu.org |
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/56889] =delete(ing) default copy and move operations for a polymorphic type gives compilation error messages
2013-04-09 6:02 [Bug c++/56889] New: =delete(ing) default copy and move operations for a polymorphic type gives compilation error messages amalisperid at yahoo dot com
2013-04-09 9:10 ` [Bug c++/56889] " daniel.kruegler at googlemail dot com
@ 2013-04-09 9:36 ` daniel.kruegler at googlemail dot com
2013-04-09 12:26 ` redi at gcc dot gnu.org
` (4 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: daniel.kruegler at googlemail dot com @ 2013-04-09 9:36 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56889
--- Comment #2 from Daniel Krügler <daniel.kruegler at googlemail dot com> 2013-04-09 09:36:29 UTC ---
(In reply to comment #1)
In addition I would like to remark that the precise declaration state of the
inherited initializer-list constructor in vector_stack is unclear, because of
http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#1573
But the existing wording implies that any usage of this constructor would be
ill-formed because of the unavailable default constructor of its base class.
>From gcc-bugs-return-419576-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Tue Apr 09 09:52:39 2013
Return-Path: <gcc-bugs-return-419576-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 3431 invoked by alias); 9 Apr 2013 09:52:38 -0000
Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm
Precedence: bulk
List-Id: <gcc-bugs.gcc.gnu.org>
List-Archive: <http://gcc.gnu.org/ml/gcc-bugs/>
List-Post: <mailto:gcc-bugs@gcc.gnu.org>
List-Help: <mailto:gcc-bugs-help@gcc.gnu.org>
Sender: gcc-bugs-owner@gcc.gnu.org
Delivered-To: mailing list gcc-bugs@gcc.gnu.org
Received: (qmail 3403 invoked by uid 48); 9 Apr 2013 09:52:36 -0000
From: "jasonwucj at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug other/56881] Miscompilation (optimisation failure?) causing NULL dereference and segfault at runtime
Date: Tue, 09 Apr 2013 09:52:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: other
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: jasonwucj at gmail dot com
X-Bugzilla-Status: UNCONFIRMED
X-Bugzilla-Priority: P3
X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org
X-Bugzilla-Target-Milestone: ---
X-Bugzilla-Changed-Fields: CC
Message-ID: <bug-56881-4-WQv1gAWxdm@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-56881-4@http.gcc.gnu.org/bugzilla/>
References: <bug-56881-4@http.gcc.gnu.org/bugzilla/>
X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/
Auto-Submitted: auto-generated
Content-Type: text/plain; charset="UTF-8"
MIME-Version: 1.0
X-SW-Source: 2013-04/txt/msg00721.txt.bz2
Content-length: 696
http://gcc.gnu.org/bugzilla/show_bug.cgi?idV881
Chung-Ju Wu <jasonwucj at gmail dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jasonwucj at gmail dot com
--- Comment #1 from Chung-Ju Wu <jasonwucj at gmail dot com> 2013-04-09 09:52:35 UTC ---
(In reply to comment #0)
>
> hs1 = (Hideset)domalloc(len*sizeof(Hideset));
> memmove(hs1, nhs, len*sizeof(Hideset));
> hidesets[nhidesets] = hs1;
>
IMHO, if domalloc() does return NULL for some cases,
having NULL-checking statement before/inside memmove is required.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/56889] =delete(ing) default copy and move operations for a polymorphic type gives compilation error messages
2013-04-09 6:02 [Bug c++/56889] New: =delete(ing) default copy and move operations for a polymorphic type gives compilation error messages amalisperid at yahoo dot com
2013-04-09 9:10 ` [Bug c++/56889] " daniel.kruegler at googlemail dot com
2013-04-09 9:36 ` daniel.kruegler at googlemail dot com
@ 2013-04-09 12:26 ` redi at gcc dot gnu.org
2013-04-09 19:02 ` amalisperid at yahoo dot com
` (3 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: redi at gcc dot gnu.org @ 2013-04-09 12:26 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56889
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution| |INVALID
--- Comment #3 from Jonathan Wakely <redi at gcc dot gnu.org> 2013-04-09 12:26:18 UTC ---
As Daniel says, you're missing a default constructor.
And if you define the type as non-copyable then obviously you can't copy it.
This is not a GCC bug.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/56889] =delete(ing) default copy and move operations for a polymorphic type gives compilation error messages
2013-04-09 6:02 [Bug c++/56889] New: =delete(ing) default copy and move operations for a polymorphic type gives compilation error messages amalisperid at yahoo dot com
` (2 preceding siblings ...)
2013-04-09 12:26 ` redi at gcc dot gnu.org
@ 2013-04-09 19:02 ` amalisperid at yahoo dot com
2013-04-09 19:13 ` daniel.kruegler at googlemail dot com
` (2 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: amalisperid at yahoo dot com @ 2013-04-09 19:02 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56889
--- Comment #4 from Amali Praveena <amalisperid at yahoo dot com> 2013-04-09 19:02:32 UTC ---
Hi Jonathan,
The Stack in the example is an abstract type, so I'm explicitly saying
that this abstract type cannot be copied or moved; but the derived class
vector_stack, which provides implementation for this abstract type is copyable
through clone function. Since the compiler won't know to which more derived
class the Stack points to at run time and so it cannot copy it, I've provided
the clone function (clone pattern).
This is what bjarne stroustrup says in his draft version of PL Fourth Edition,
as I quoted before.
Here is that section from the book.
3.3.4 Prev enting Copy and Move [tour2.copy.hier]
Using the default copy or move for a class in a hierarchy is typically a
disaster: Given only
a pointer to a base, we simply don’t know what members the derived class has
(§3.3.3), so
we can’t know how to copy them. So, the best thing to do is usually to delete
the default
copy and move operations; that is, to eliminate to default definitions of those
two operations:
class Shape {
public:
Sha pe(const Sha pe&) =delete; // no copy operations
Sha pe& opera tor=(const Sha pe&) =delete;
Sha pe(Sha pe&&) =delete; // no move operations
Sha pe& opera tor=(Shape&&) =delete;
˜Sha pe();
// ...
};
Now an attempt to copy a Sha pe will be caught by the compiler. If you need to
copy an
object in a class hierarchy, write some kind of clone function (§22.2.4).
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. D R A F T
Thanks,
Amali.
________________________________
From: redi at gcc dot gnu.org <gcc-bugzilla@gcc.gnu.org>
To: amalisperid@yahoo.com
Sent: Tuesday, 9 April 2013 10:26 PM
Subject: [Bug c++/56889] =delete(ing) default copy and move operations for a
polymorphic type gives compilation error messages
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56889
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution| |INVALID
--- Comment #3 from Jonathan Wakely <redi at gcc dot gnu.org> 2013-04-09
12:26:18 UTC ---
As Daniel says, you're missing a default constructor.
And if you define the type as non-copyable then obviously you can't copy it.
This is not a GCC bug.
>From gcc-bugs-return-419647-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Tue Apr 09 19:08:58 2013
Return-Path: <gcc-bugs-return-419647-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 3842 invoked by alias); 9 Apr 2013 19:08:58 -0000
Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm
Precedence: bulk
List-Id: <gcc-bugs.gcc.gnu.org>
List-Archive: <http://gcc.gnu.org/ml/gcc-bugs/>
List-Post: <mailto:gcc-bugs@gcc.gnu.org>
List-Help: <mailto:gcc-bugs-help@gcc.gnu.org>
Sender: gcc-bugs-owner@gcc.gnu.org
Delivered-To: mailing list gcc-bugs@gcc.gnu.org
Received: (qmail 3798 invoked by uid 48); 9 Apr 2013 19:08:53 -0000
From: "rmansfield at qnx dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/56896] New: Missing DIR_SEPARATOR if --with-gxx-include-dir configured as subdir of sysroot
Date: Tue, 09 Apr 2013 19:08:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: new
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: c++
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: rmansfield at qnx dot com
X-Bugzilla-Status: UNCONFIRMED
X-Bugzilla-Priority: P3
X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org
X-Bugzilla-Target-Milestone: ---
X-Bugzilla-Changed-Fields:
Message-ID: <bug-56896-4@http.gcc.gnu.org/bugzilla/>
X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/
Auto-Submitted: auto-generated
Content-Type: text/plain; charset="UTF-8"
MIME-Version: 1.0
X-SW-Source: 2013-04/txt/msg00792.txt.bz2
Content-length: 4860
http://gcc.gnu.org/bugzilla/show_bug.cgi?idV896
Bug #: 56896
Summary: Missing DIR_SEPARATOR if --with-gxx-include-dir
configured as subdir of sysroot
Classification: Unclassified
Product: gcc
Version: 4.9.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: rmansfield@qnx.com
If gcc is configured with --with-sysroot=<path> and
--with-gxx-include-dir=<path>/<subpath> then gcc_gxx_include_dir will end up as
a relative path, and then incpath.c will trip the trailing sysroot
DIR_SEPARATOR and construct an invalid path.
e.g.
~/gnu/gcc/trunk/tmp/gcc$ ./xgcc -v
Using built-in specs.
COLLECT_GCC=./xgcc
Target: x86_64-unknown-linux-gnu
Configured with: ../configure --enable-languages=c++ --disable-bootstrap
--with-gxx-include-dir=/home/ryan/foo/bar/usr/include/4.9.0
--with-sysroot=/home/ryan/foo/bar/
Thread model: posix
gcc version 4.9.0 20130409 (experimental) [trunk revision 197644] (GCC)
## --------- ##
## Platform. ##
~/gnu/gcc/trunk/tmp$ grep -nr gcc_gxx_include_dir *
gcc/Makefile:623:gcc_gxx_include_dir = usr/include/4.9.0
gcc/Makefile:624:gcc_gxx_include_dir_add_sysroot = 1
gcc/Makefile:1108: "gxx_include_dir=$(gcc_gxx_include_dir)" \
gcc/Makefile:4055: -DGPLUSPLUS_INCLUDE_DIR=\"$(gcc_gxx_include_dir)\" \
gcc/Makefile:4056:
-DGPLUSPLUS_INCLUDE_DIR_ADD_SYSROOT=$(gcc_gxx_include_dir_add_sysroot) \
gcc/Makefile:4057:
-DGPLUSPLUS_TOOL_INCLUDE_DIR=\"$(gcc_gxx_include_dir)/$(target_noncanonical)\"
\
gcc/Makefile:4058:
-DGPLUSPLUS_BACKWARD_INCLUDE_DIR=\"$(gcc_gxx_include_dir)/backward\" \
gcc/config.log:6339:gcc_gxx_include_dir='usr/include/4.9.0'
gcc/config.log:6340:gcc_gxx_include_dir_add_sysroot='1'
gcc/config.status:682:S["gcc_gxx_include_dir_add_sysroot"]="1"
gcc/config.status:683:S["gcc_gxx_include_dir"]="usr/include/4.9.0"
~/gnu/gcc/trunk/tmp/gcc$ ./xgcc -B. ~/hw.cc -v
Reading specs from ./specs
COLLECT_GCC=./xgcc
COLLECT_LTO_WRAPPER=./lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: ../configure --enable-languages=c++ --disable-bootstrap
--with-gxx-include-dir=/home/ryan/foo/bar/usr/include/4.9.0
--with-sysroot=/home/ryan/foo/bar/
Thread model: posix
gcc version 4.9.0 20130409 (experimental) [trunk revision 197644] (GCC)
COLLECT_GCC_OPTIONS='-B' '.' '-v' '-mtune=generic' '-march=x86-64'
./cc1plus -quiet -v -iprefix
/home/ryan/gnu/gcc/trunk/tmp/gcc/../lib/gcc/x86_64-unknown-linux-gnu/4.9.0/
-isystem ./include -isystem ./include-fixed -D_GNU_SOURCE /home/ryan/hw.cc
-quiet -dumpbase hw.cc -mtune=generic -march=x86-64 -auxbase hw -version -o
/tmp/cclOMQFL.s
GNU C++ (GCC) version 4.9.0 20130409 (experimental) [trunk revision 197644]
(x86_64-unknown-linux-gnu)
compiled by GNU C version 4.7.2, GMP version 5.0.2, MPFR version 3.1.0-p3,
MPC version 0.9
GGC heuristics: --param ggc-min-expand0 --param ggc-min-heapsize@96
ignoring nonexistent directory
"/home/ryan/gnu/gcc/trunk/tmp/gcc/../lib/gcc/x86_64-unknown-linux-gnu/4.9.0/include"
ignoring nonexistent directory
"/home/ryan/gnu/gcc/trunk/tmp/gcc/../lib/gcc/x86_64-unknown-linux-gnu/4.9.0/include-fixed"
ignoring nonexistent directory
"/home/ryan/gnu/gcc/trunk/tmp/gcc/../lib/gcc/x86_64-unknown-linux-gnu/4.9.0/../../../../x86_64-unknown-linux-gnu/include"
ignoring nonexistent directory "/home/ryan/foo/barusr/include/4.9.0"
ignoring nonexistent directory
"/home/ryan/foo/barusr/include/4.9.0/x86_64-unknown-linux-gnu"
ignoring nonexistent directory "/home/ryan/foo/barusr/include/4.9.0/backward"
<snip>
Or:
~/gnu/gcc/trunk/tmp/gcc$ ./xgcc -B. ~/hw.cc --sysroot=/foo/bar
<snip>
ignoring nonexistent directory "/foo/barusr/include/4.9.0"
ignoring nonexistent directory
"/foo/barusr/include/4.9.0/x86_64-unknown-linux-gnu"
ignoring nonexistent directory "/foo/barusr/include/4.9.0/backward"
I'm not sure if the following is sufficient, or if the gcc_gxx_include_dir
should never end up without a leading DIR_SEPARATOR.
Index: gcc/incpath.c
==================================================================--- gcc/incpath.c (revision 197644)
+++ gcc/incpath.c (working copy)
@@ -179,7 +179,8 @@
char *sysroot_no_trailing_dir_separator = xstrdup (sysroot);
size_t sysroot_len = strlen (sysroot);
- if (sysroot_len > 0 && sysroot[sysroot_len - 1] == DIR_SEPARATOR)
+ if (sysroot_len > 0 && sysroot[sysroot_len - 1] == DIR_SEPARATOR
+ && p->fname[0] == DIR_SEPARATOR)
sysroot_no_trailing_dir_separator[sysroot_len - 1] = '\0';
str = concat (sysroot_no_trailing_dir_separator, p->fname, NULL);
free (sysroot_no_trailing_dir_separator);
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/56889] =delete(ing) default copy and move operations for a polymorphic type gives compilation error messages
2013-04-09 6:02 [Bug c++/56889] New: =delete(ing) default copy and move operations for a polymorphic type gives compilation error messages amalisperid at yahoo dot com
` (3 preceding siblings ...)
2013-04-09 19:02 ` amalisperid at yahoo dot com
@ 2013-04-09 19:13 ` daniel.kruegler at googlemail dot com
2013-04-11 12:42 ` redi at gcc dot gnu.org
2013-04-12 3:39 ` amalisperid at yahoo dot com
6 siblings, 0 replies; 8+ messages in thread
From: daniel.kruegler at googlemail dot com @ 2013-04-09 19:13 UTC (permalink / raw)
To: gcc-bugs
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="UTF-8", Size: 9128 bytes --]
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56889
--- Comment #5 from Daniel Krügler <daniel.kruegler at googlemail dot com> 2013-04-09 19:13:55 UTC ---
This issue is not the right place for discussing programming idioms, but as a
last comment to the code: Your reference to PL alone does not solve your
programing error: You need to define a copy constructor in vector_stack,
because the compiler-defined one is also deleted (because of the deleted one in
the base class), or define the clone function without a copy constructor.
>From gcc-bugs-return-419649-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Tue Apr 09 19:23:42 2013
Return-Path: <gcc-bugs-return-419649-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 12193 invoked by alias); 9 Apr 2013 19:23:42 -0000
Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm
Precedence: bulk
List-Id: <gcc-bugs.gcc.gnu.org>
List-Archive: <http://gcc.gnu.org/ml/gcc-bugs/>
List-Post: <mailto:gcc-bugs@gcc.gnu.org>
List-Help: <mailto:gcc-bugs-help@gcc.gnu.org>
Sender: gcc-bugs-owner@gcc.gnu.org
Delivered-To: mailing list gcc-bugs@gcc.gnu.org
Received: (qmail 12172 invoked by uid 55); 9 Apr 2013 19:23:39 -0000
From: "amalisperid at yahoo dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/56889] Þlete(ing) default copy and move operations for a polymorphic type gives compilation error messages
Date: Tue, 09 Apr 2013 19:23:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: c++
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: amalisperid at yahoo dot com
X-Bugzilla-Status: RESOLVED
X-Bugzilla-Priority: P3
X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org
X-Bugzilla-Target-Milestone: ---
X-Bugzilla-Changed-Fields:
Message-ID: <bug-56889-4-dmrZmpFzzu@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-56889-4@http.gcc.gnu.org/bugzilla/>
References: <bug-56889-4@http.gcc.gnu.org/bugzilla/>
X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/
Auto-Submitted: auto-generated
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
MIME-Version: 1.0
X-SW-Source: 2013-04/txt/msg00794.txt.bz2
Content-length: 5023
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56889
--- Comment #6 from Amali Praveena <amalisperid at yahoo dot com> 2013-04-09 19:23:38 UTC ---
Hi Daniel,
The Stack template is an abstract type, so I don't have to add default
constructor to it, do I? Since the abstract type can't be copied/moved, i'm
explicitly specifying those functions as delete; but the derived classes
(vector_stack) are copyable through clone function(clone pattern).
 I tried to do the following (adding default constructor), which still gave me
an error(both options):
template<class T>
class Stack{
  public:
  // pure virtual member functions
  virtual Stack* clone() const=0; // polymorphic
  virtual ~Stack() {} // explicitly define a destructor
  // no copy operations Bug No:- 56889
  Stack() // option 1
  {
  }
  Stack()=default; // option 2
  Stack(const Stack&)=delete;
  Stack& operator=(const Stack&)=delete;
  //no move operations
  Stack(Stack&&)=delete;
  Stack& operator=(Stack&&)=delete;
  virtual bool empty() const=0; // const member function
  virtual std::size_t size() const=0; // const member function
  virtual T& top()=0;
  virtual const T& top() const=0; // const member function
  virtual void push(const T& x)=0;
  virtual void pop()=0;
};
Here is a section from Bjarne stroustrup's PL fourth edition draft version :
Preventing Copy and Move [tour2.copy.hier]
Using the default copy or move for a class in a hierarchy is typically a
disaster: Given only
a pointer to a base, we simply donât know what members the derived class has
(§3.3.3), so
we canât know how to copy them. So, the best thing to do is usually to delete
the default
copy and move operations; that is, to eliminate to default deï¬nitions of those
two operations:
class Shape {
public:
Sha pe(const Sha pe&) =delete; // no copy operations
Sha pe& opera tor=(const Sha pe&) =delete;
Sha pe(Sha pe&&) =delete; // no move operations
Sha pe& opera tor=(Shape&&) =delete;
ËSha pe();
// ...
};
Now an attempt to copy a Sha pe will be caught by the compiler. If you need to
copy an
object in a class hierarchy, write some kind of clone function (§22.2.4).
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 deï¬ne a destructor even
where the compiler
would have implicitly provided one (§17.2.3).
A base class in a class hierarchy is just one example of an object we wouldnât
want to
copy.
The C++ Programming Language, 4th edition ©2012 by Pearson Education, Inc.
Reproduced in draft form with the permission of the publisher. D R A F T
thanks,
Amali.
________________________________
From: daniel.kruegler at googlemail dot com <gcc-bugzilla@gcc.gnu.org>
To: amalisperid@yahoo.com
Sent: Tuesday, 9 April 2013 7:10 PM
Subject: [Bug c++/56889] =delete(ing) default copy and move operations for a
polymorphic type gives compilation error messages
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56889
Daniel Krügler <daniel.kruegler at googlemail dot com> changed:
     What  |Removed          |Added
----------------------------------------------------------------------------
        CC|              |daniel.kruegler at
         |              |googlemail dot com
--- Comment #1 from Daniel Krügler <daniel.kruegler at googlemail dot com>
2013-04-09 09:10:52 UTC ---
There are several problems in your example:
1) You have not declared a default constructor in template Stack, but you have
provided user-declared constructors (The deleted ones). This has the effect
that the Stack template has a no implicitly declared default constructor, which
again has the effect that the initializer-list constructor generated by the
compiler in vector_stack is deleted, because it would implicitly call the
missing default constructor of Stack. Solution: Add a (defaulted) default
constructor to the Stack template.
2) The clone function in vector_stack would call the copy constructor of that
type. But this one is deleted, because the Stack template has an explicitly
deleted copy constructor. This is a design error.
>From gcc-bugs-return-419650-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Tue Apr 09 19:38:19 2013
Return-Path: <gcc-bugs-return-419650-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 21271 invoked by alias); 9 Apr 2013 19:38:19 -0000
Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm
Precedence: bulk
List-Id: <gcc-bugs.gcc.gnu.org>
List-Archive: <http://gcc.gnu.org/ml/gcc-bugs/>
List-Post: <mailto:gcc-bugs@gcc.gnu.org>
List-Help: <mailto:gcc-bugs-help@gcc.gnu.org>
Sender: gcc-bugs-owner@gcc.gnu.org
Delivered-To: mailing list gcc-bugs@gcc.gnu.org
Received: (qmail 21224 invoked by uid 48); 9 Apr 2013 19:38:16 -0000
From: "aschepler at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/51424] [C++11] G++ should diagnose self-delegating constructors
Date: Tue, 09 Apr 2013 19:38:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: c++
X-Bugzilla-Keywords: diagnostic
X-Bugzilla-Severity: normal
X-Bugzilla-Who: aschepler at gmail dot com
X-Bugzilla-Status: UNCONFIRMED
X-Bugzilla-Priority: P3
X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org
X-Bugzilla-Target-Milestone: ---
X-Bugzilla-Changed-Fields:
Message-ID: <bug-51424-4-O5PWh9bIM4@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-51424-4@http.gcc.gnu.org/bugzilla/>
References: <bug-51424-4@http.gcc.gnu.org/bugzilla/>
X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/
Auto-Submitted: auto-generated
Content-Type: text/plain; charset="UTF-8"
MIME-Version: 1.0
X-SW-Source: 2013-04/txt/msg00795.txt.bz2
Content-length: 550
http://gcc.gnu.org/bugzilla/show_bug.cgi?idQ424
--- Comment #1 from Andrew Schepler <aschepler at gmail dot com> 2013-04-09 19:38:15 UTC ---
The diagnostic is easy in the direct case of delegating to the same
constructor, but difficult in the indirect case of multiple delegating
constructors. (The condition might still be detectable if enough constructors
can be inlined.) This difficulty is presumably why the Standard specifies "no
diagnostic required".
But yes, it seems like a good idea to support a warning for the easy case.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/56889] =delete(ing) default copy and move operations for a polymorphic type gives compilation error messages
2013-04-09 6:02 [Bug c++/56889] New: =delete(ing) default copy and move operations for a polymorphic type gives compilation error messages amalisperid at yahoo dot com
` (4 preceding siblings ...)
2013-04-09 19:13 ` daniel.kruegler at googlemail dot com
@ 2013-04-11 12:42 ` redi at gcc dot gnu.org
2013-04-12 3:39 ` amalisperid at yahoo dot com
6 siblings, 0 replies; 8+ messages in thread
From: redi at gcc dot gnu.org @ 2013-04-11 12:42 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56889
--- Comment #7 from Jonathan Wakely <redi at gcc dot gnu.org> 2013-04-11 12:42:52 UTC ---
You keep quoting Stroustrup but your code is still broken.
Your clone() function copies the object. The object is not copyable. What is
so difficult to understand?
Add a copy constructor to vector_stack or change the clone function.
This is not a GCC bug!
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/56889] =delete(ing) default copy and move operations for a polymorphic type gives compilation error messages
2013-04-09 6:02 [Bug c++/56889] New: =delete(ing) default copy and move operations for a polymorphic type gives compilation error messages amalisperid at yahoo dot com
` (5 preceding siblings ...)
2013-04-11 12:42 ` redi at gcc dot gnu.org
@ 2013-04-12 3:39 ` amalisperid at yahoo dot com
6 siblings, 0 replies; 8+ messages in thread
From: amalisperid at yahoo dot com @ 2013-04-12 3:39 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56889
--- Comment #8 from Amali Praveena <amalisperid at yahoo dot com> 2013-04-12 03:39:35 UTC ---
Hi reddit,
Yes, it's not a GCC bug. I had a problem with copy constructors in version
4.7.0 but got Internal Compilation Error. I'm now working with GCC 4.8.0 in
which this is fixed. I think I got confused with this.
I thought of adding these delete functions to the abstract class and test it.
Since vector_stack doesn't have any pointer members/ members of its own, I can
rely on compiler to generate a default copy constructor for this more derived
class of Stack.
Option 1:
As you say, because I have made copy/move operations in the abstract
type(Stack) =delete, I think I should define a default copy
constructor/assignment and move constructor/assignment in all more derived
classes of Stack.
Option 2:
Change the clone function. However, Clone pattern is often implemented using
copy constructor. Until now, I haven't seen it done in some other ways.
Thanks,
Amali.
________________________________
From: redi at gcc dot gnu.org <gcc-bugzilla@gcc.gnu.org>
To: amalisperid@yahoo.com
Sent: Thursday, 11 April 2013 10:42 PM
Subject: [Bug c++/56889] =delete(ing) default copy and move operations for a
polymorphic type gives compilation error messages
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56889
--- Comment #7 from Jonathan Wakely <redi at gcc dot gnu.org> 2013-04-11
12:42:52 UTC ---
You keep quoting Stroustrup but your code is still broken.
Your clone() function copies the object. The object is not copyable. What is
so difficult to understand?
Add a copy constructor to vector_stack or change the clone function.
This is not a GCC bug!
>From gcc-bugs-return-419885-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Fri Apr 12 03:45:47 2013
Return-Path: <gcc-bugs-return-419885-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 28544 invoked by alias); 12 Apr 2013 03:45:46 -0000
Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm
Precedence: bulk
List-Id: <gcc-bugs.gcc.gnu.org>
List-Archive: <http://gcc.gnu.org/ml/gcc-bugs/>
List-Post: <mailto:gcc-bugs@gcc.gnu.org>
List-Help: <mailto:gcc-bugs-help@gcc.gnu.org>
Sender: gcc-bugs-owner@gcc.gnu.org
Delivered-To: mailing list gcc-bugs@gcc.gnu.org
Received: (qmail 28521 invoked by uid 48); 12 Apr 2013 03:45:43 -0000
From: "vapier at gentoo dot org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c/56928] New: false positive when using -Wstrict-overflow
Date: Fri, 12 Apr 2013 03:45:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: new
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: c
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: vapier at gentoo dot org
X-Bugzilla-Status: UNCONFIRMED
X-Bugzilla-Priority: P3
X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org
X-Bugzilla-Target-Milestone: ---
X-Bugzilla-Changed-Fields:
Message-ID: <bug-56928-4@http.gcc.gnu.org/bugzilla/>
X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/
Auto-Submitted: auto-generated
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
MIME-Version: 1.0
X-SW-Source: 2013-04/txt/msg01030.txt.bz2
Content-length: 1323
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56928
Bug #: 56928
Summary: false positive when using -Wstrict-overflow
Classification: Unclassified
Product: gcc
Version: 4.8.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: vapier@gentoo.org
Target: x86_64-linux-gnu
i've got some code that is triggering a warning when using gcc-4.8.0 and -O2
with -Wstrict-overflow. pretty sure the warning is wrong -- when i tweak the
code slightly (in unrelated ways), it goes away.
playing with older versions shows that 4.[234].x work, but 4.[5678].x fail
the reduced test case:
$ cat test.i
struct stat {
int st_mode;
};
const char *foo(char c, int x, struct stat s)
{
int i;
char dynamic = 0;
if (c == 1)
for (i = 0; i < x; i++)
dynamic = 1;
if (!dynamic || !(s.st_mode & 1))
return dynamic ? "d" : "!d";
}
$ gcc -O2 -c test.i -Wstrict-overflow
test.i: In function ‘foo’:
test.i:12:24: warning: assuming signed overflow does not occur when simplifying
conditional to constant [-Wstrict-overflow]
return dynamic ? "d" : "!d";
^
>From gcc-bugs-return-419886-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Fri Apr 12 05:06:30 2013
Return-Path: <gcc-bugs-return-419886-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 19181 invoked by alias); 12 Apr 2013 05:06:30 -0000
Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm
Precedence: bulk
List-Id: <gcc-bugs.gcc.gnu.org>
List-Archive: <http://gcc.gnu.org/ml/gcc-bugs/>
List-Post: <mailto:gcc-bugs@gcc.gnu.org>
List-Help: <mailto:gcc-bugs-help@gcc.gnu.org>
Sender: gcc-bugs-owner@gcc.gnu.org
Delivered-To: mailing list gcc-bugs@gcc.gnu.org
Received: (qmail 19108 invoked by uid 48); 12 Apr 2013 05:06:26 -0000
From: "pinskia at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug tree-optimization/56928] [4.6/4.7/4.8/4.9 Regression] false positive when using -Wstrict-overflow
Date: Fri, 12 Apr 2013 05:06:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: tree-optimization
X-Bugzilla-Keywords: diagnostic
X-Bugzilla-Severity: normal
X-Bugzilla-Who: pinskia at gcc dot gnu.org
X-Bugzilla-Status: NEW
X-Bugzilla-Priority: P3
X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org
X-Bugzilla-Target-Milestone: 4.6.4
X-Bugzilla-Changed-Fields: Keywords Status Last reconfirmed Component Target Milestone Summary Ever Confirmed
Message-ID: <bug-56928-4-5LkFz8y9Ar@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-56928-4@http.gcc.gnu.org/bugzilla/>
References: <bug-56928-4@http.gcc.gnu.org/bugzilla/>
X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/
Auto-Submitted: auto-generated
Content-Type: text/plain; charset="UTF-8"
MIME-Version: 1.0
X-SW-Source: 2013-04/txt/msg01031.txt.bz2
Content-length: 1440
http://gcc.gnu.org/bugzilla/show_bug.cgi?idV928
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |diagnostic
Status|UNCONFIRMED |NEW
Last reconfirmed| |2013-04-12
Component|c |tree-optimization
Target Milestone|--- |4.6.4
Summary|false positive when using |[4.6/4.7/4.8/4.9
|-Wstrict-overflow |Regression] false positive
| |when using
| |-Wstrict-overflow
Ever Confirmed|0 |1
--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> 2013-04-12 05:06:26 UTC ---
Visiting PHI node: dynamic_3 = PHI <0(2), dynamic_2(11)>
Argument #0 (2 -> 5 executable)
0
Value: [0, 0]
Argument #1 (11 -> 5 executable)
dynamic_2
Value: [0, 1]
Meeting
[0, 0]
and
[0, 1]
to
[0, 1]
Found new range for dynamic_3: [0, +INF(OVF)]
I don't see any overflow there or even a way to cause the overflow.
Looks like there is a bad type issue, dynamic is char but it is being treated
as a boolean type internally.
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2013-04-12 3:39 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-04-09 6:02 [Bug c++/56889] New: =delete(ing) default copy and move operations for a polymorphic type gives compilation error messages amalisperid at yahoo dot com
2013-04-09 9:10 ` [Bug c++/56889] " daniel.kruegler at googlemail dot com
2013-04-09 9:36 ` daniel.kruegler at googlemail dot com
2013-04-09 12:26 ` redi at gcc dot gnu.org
2013-04-09 19:02 ` amalisperid at yahoo dot com
2013-04-09 19:13 ` daniel.kruegler at googlemail dot com
2013-04-11 12:42 ` redi at gcc dot gnu.org
2013-04-12 3:39 ` amalisperid at yahoo 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).