public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
* [Bug c++/43452] New: Array delete causes error on incomplete type @ 2010-03-20 0:38 yy2bggggs at gmail dot com 2010-03-20 0:57 ` [Bug c++/43452] " redi at gcc dot gnu dot org ` (2 more replies) 0 siblings, 3 replies; 9+ messages in thread From: yy2bggggs at gmail dot com @ 2010-03-20 0:38 UTC (permalink / raw) To: gcc-bugs This code: class Foo; int main() { Foo* p; delete [] p; } Produces this error: dt.cpp:6: error: invalid use of incomplete type `struct Foo' dt.cpp:1: error: forward declaration of `struct Foo' ...but shouldn't it compile? With: g++ -c -std=c++98 ...on 4.3.4 20090804 (release) 1 in Cygwin; and: ...on 4.1.2 20080704 (Red Hat 4.1.2-44) The ordinary form works just fine; replace "delete [] p;" with "delete p;", and: dt.cpp: In function `int main()': dt.cpp:6: warning: possible problem detected in invocation of delete operator: dt.cpp:5: warning: `p' has incomplete type dt.cpp:1: warning: forward declaration of `struct Foo' dt.cpp:6: note: neither the destructor nor the class-specific operator delete will be called, even if they are declared when the class is defined. ...on 4.3.4 20090804 system, and: ...on 4.1.2 20080704 system. -- Summary: Array delete causes error on incomplete type Product: gcc Version: unknown Status: UNCONFIRMED Severity: minor Priority: P3 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: yy2bggggs at gmail dot com GCC host triplet: 4.3.4 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43452 ^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/43452] Array delete causes error on incomplete type 2010-03-20 0:38 [Bug c++/43452] New: Array delete causes error on incomplete type yy2bggggs at gmail dot com @ 2010-03-20 0:57 ` redi at gcc dot gnu dot org 2010-03-20 1:03 ` redi at gcc dot gnu dot org 2010-03-20 11:27 ` bangerth at gmail dot com 2 siblings, 0 replies; 9+ messages in thread From: redi at gcc dot gnu dot org @ 2010-03-20 0:57 UTC (permalink / raw) To: gcc-bugs ------- Comment #1 from redi at gcc dot gnu dot org 2010-03-20 00:57 ------- It's undefined behaviour -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43452 ^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/43452] Array delete causes error on incomplete type 2010-03-20 0:38 [Bug c++/43452] New: Array delete causes error on incomplete type yy2bggggs at gmail dot com 2010-03-20 0:57 ` [Bug c++/43452] " redi at gcc dot gnu dot org @ 2010-03-20 1:03 ` redi at gcc dot gnu dot org 2010-03-20 11:27 ` bangerth at gmail dot com 2 siblings, 0 replies; 9+ messages in thread From: redi at gcc dot gnu dot org @ 2010-03-20 1:03 UTC (permalink / raw) To: gcc-bugs ------- Comment #2 from redi at gcc dot gnu dot org 2010-03-20 01:03 ------- Hmm, on second thoughts... Technically that program has undefined behaviour because p does not have a value that comes from a previous new expression, however this variation is not undefined as long as Foo has a trivial destructor, and f returns a pointer to an array of Foo: class Foo; Foo* f(); int main() { Foo* p = f(); delete [] p; } -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43452 ^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/43452] Array delete causes error on incomplete type 2010-03-20 0:38 [Bug c++/43452] New: Array delete causes error on incomplete type yy2bggggs at gmail dot com 2010-03-20 0:57 ` [Bug c++/43452] " redi at gcc dot gnu dot org 2010-03-20 1:03 ` redi at gcc dot gnu dot org @ 2010-03-20 11:27 ` bangerth at gmail dot com 2 siblings, 0 replies; 9+ messages in thread From: bangerth at gmail dot com @ 2010-03-20 11:27 UTC (permalink / raw) To: gcc-bugs ------- Comment #3 from bangerth at gmail dot com 2010-03-20 11:26 ------- (In reply to comment #2) > class Foo; > Foo* f(); > int main() { > Foo* p = f(); > delete [] p; > } I can't see how the compiler could possibly do anything useful in this case if Foo is incomplete. I can't find any statement that would say that the code is ill-formed, however. If there really is no such statement, I still don't think we should make it a priority to compile this code without an error. W. -- bangerth at gmail dot com changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |bangerth at gmail dot com http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43452 ^ permalink raw reply [flat|nested] 9+ messages in thread
[parent not found: <bug-43452-4@http.gcc.gnu.org/bugzilla/>]
* [Bug c++/43452] Array delete causes error on incomplete type [not found] <bug-43452-4@http.gcc.gnu.org/bugzilla/> @ 2013-09-05 22:30 ` paolo.carlini at oracle dot com 2013-09-09 14:31 ` paolo at gcc dot gnu.org ` (3 subsequent siblings) 4 siblings, 0 replies; 9+ messages in thread From: paolo.carlini at oracle dot com @ 2013-09-05 22:30 UTC (permalink / raw) To: gcc-bugs http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43452 Paolo Carlini <paolo.carlini at oracle dot com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC|gcc-bugs at gcc dot gnu.org | Assignee|unassigned at gcc dot gnu.org |paolo.carlini at oracle dot com --- Comment #4 from Paolo Carlini <paolo.carlini at oracle dot com> --- Let's resolve this. ^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/43452] Array delete causes error on incomplete type [not found] <bug-43452-4@http.gcc.gnu.org/bugzilla/> 2013-09-05 22:30 ` paolo.carlini at oracle dot com @ 2013-09-09 14:31 ` paolo at gcc dot gnu.org 2013-09-09 14:32 ` paolo.carlini at oracle dot com ` (2 subsequent siblings) 4 siblings, 0 replies; 9+ messages in thread From: paolo at gcc dot gnu.org @ 2013-09-09 14:31 UTC (permalink / raw) To: gcc-bugs http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43452 --- Comment #5 from paolo at gcc dot gnu.org <paolo at gcc dot gnu.org> --- Author: paolo Date: Mon Sep 9 14:31:16 2013 New Revision: 202404 URL: http://gcc.gnu.org/viewcvs?rev=202404&root=gcc&view=rev Log: 2013-09-09 Paolo Carlini <paolo.carlini@oracle.com> PR c++/43452 * doc/invoke.texi (-Wdelete-incomplete): Document it. /c-family 2013-09-09 Paolo Carlini <paolo.carlini@oracle.com> PR c++/43452 * c.opt (Wdelete-incomplete): Add. /cp 2013-09-09 Paolo Carlini <paolo.carlini@oracle.com> PR c++/43452 * init.c (build_vec_delete_1): When the type is incomplete emit a warning, enabled by default (not an error). (build_delete): Adjust to use OPT_Wdelete_incomplete. /testsuite 2013-09-09 Paolo Carlini <paolo.carlini@oracle.com> PR c++/43452 * g++.dg/warn/Wdelete-incomplete-1.C: New. * g++.dg/warn/Wdelete-incomplete-2.C: Likewise. * g++.dg/init/delete1.C: Adjust. Added: trunk/gcc/testsuite/g++.dg/warn/Wdelete-incomplete-1.C trunk/gcc/testsuite/g++.dg/warn/Wdelete-incomplete-2.C Modified: trunk/gcc/ChangeLog trunk/gcc/c-family/ChangeLog trunk/gcc/c-family/c.opt trunk/gcc/cp/ChangeLog trunk/gcc/cp/init.c trunk/gcc/doc/invoke.texi trunk/gcc/testsuite/g++.dg/init/delete1.C ^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/43452] Array delete causes error on incomplete type [not found] <bug-43452-4@http.gcc.gnu.org/bugzilla/> 2013-09-05 22:30 ` paolo.carlini at oracle dot com 2013-09-09 14:31 ` paolo at gcc dot gnu.org @ 2013-09-09 14:32 ` paolo.carlini at oracle dot com 2013-09-09 14:47 ` paolo at gcc dot gnu.org 2014-04-16 16:42 ` redi at gcc dot gnu.org 4 siblings, 0 replies; 9+ messages in thread From: paolo.carlini at oracle dot com @ 2013-09-09 14:32 UTC (permalink / raw) To: gcc-bugs http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43452 Paolo Carlini <paolo.carlini at oracle dot com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |RESOLVED Resolution|--- |FIXED Target Milestone|--- |4.9.0 --- Comment #6 from Paolo Carlini <paolo.carlini at oracle dot com> --- Fixed for 4.9.0. ^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/43452] Array delete causes error on incomplete type [not found] <bug-43452-4@http.gcc.gnu.org/bugzilla/> ` (2 preceding siblings ...) 2013-09-09 14:32 ` paolo.carlini at oracle dot com @ 2013-09-09 14:47 ` paolo at gcc dot gnu.org 2014-04-16 16:42 ` redi at gcc dot gnu.org 4 siblings, 0 replies; 9+ messages in thread From: paolo at gcc dot gnu.org @ 2013-09-09 14:47 UTC (permalink / raw) To: gcc-bugs http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43452 --- Comment #7 from paolo at gcc dot gnu.org <paolo at gcc dot gnu.org> --- Author: paolo Date: Mon Sep 9 14:47:21 2013 New Revision: 202405 URL: http://gcc.gnu.org/viewcvs?rev=202405&root=gcc&view=rev Log: 2013-09-09 Paolo Carlini <paolo.carlini@oracle.com> PR c++/43452 * doc/invoke.texi (-Wdelete-incomplete): Document it. /c-family 2013-09-09 Paolo Carlini <paolo.carlini@oracle.com> PR c++/43452 * c.opt (Wdelete-incomplete): Add. /cp 2013-09-09 Paolo Carlini <paolo.carlini@oracle.com> PR c++/43452 * init.c (build_vec_delete_1): When the type is incomplete emit a warning, enabled by default (not an error). (build_delete): Adjust to use OPT_Wdelete_incomplete. /testsuite 2013-09-09 Paolo Carlini <paolo.carlini@oracle.com> PR c++/43452 * g++.dg/warn/Wdelete-incomplete-1.C: New. * g++.dg/warn/Wdelete-incomplete-2.C: Likewise. * g++.dg/init/delete1.C: Adjust. Modified: trunk/gcc/testsuite/ChangeLog ^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/43452] Array delete causes error on incomplete type [not found] <bug-43452-4@http.gcc.gnu.org/bugzilla/> ` (3 preceding siblings ...) 2013-09-09 14:47 ` paolo at gcc dot gnu.org @ 2014-04-16 16:42 ` redi at gcc dot gnu.org 4 siblings, 0 replies; 9+ messages in thread From: redi at gcc dot gnu.org @ 2014-04-16 16:42 UTC (permalink / raw) To: gcc-bugs http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43452 Jonathan Wakely <redi at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |tilman.vogel at web dot de --- Comment #8 from Jonathan Wakely <redi at gcc dot gnu.org> --- *** Bug 58114 has been marked as a duplicate of this bug. *** ^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2014-04-16 16:42 UTC | newest] Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2010-03-20 0:38 [Bug c++/43452] New: Array delete causes error on incomplete type yy2bggggs at gmail dot com 2010-03-20 0:57 ` [Bug c++/43452] " redi at gcc dot gnu dot org 2010-03-20 1:03 ` redi at gcc dot gnu dot org 2010-03-20 11:27 ` bangerth at gmail dot com [not found] <bug-43452-4@http.gcc.gnu.org/bugzilla/> 2013-09-05 22:30 ` paolo.carlini at oracle dot com 2013-09-09 14:31 ` paolo at gcc dot gnu.org 2013-09-09 14:32 ` paolo.carlini at oracle dot com 2013-09-09 14:47 ` paolo at gcc dot gnu.org 2014-04-16 16:42 ` redi at gcc dot gnu.org
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).