public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/58876] No non-virtual-dtor warning in std::unique_ptr
[not found] <bug-58876-4@http.gcc.gnu.org/bugzilla/>
@ 2013-10-30 15:04 ` redi at gcc dot gnu.org
2013-10-30 17:57 ` paolo.carlini at oracle dot com
` (13 subsequent siblings)
14 siblings, 0 replies; 15+ messages in thread
From: redi at gcc dot gnu.org @ 2013-10-30 15:04 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58876
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |diagnostic
Status|UNCONFIRMED |NEW
Last reconfirmed| |2013-10-30
Component|c++ |libstdc++
Ever confirmed|0 |1
--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
This is because warnings are suppressed by default in system headers, and the
undefined delete operation occurs in a system header. You get the warning if
you use -Wsystem-headers
I don't see an easy way to force the warning to always be emitted though.
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug libstdc++/58876] No non-virtual-dtor warning in std::unique_ptr
[not found] <bug-58876-4@http.gcc.gnu.org/bugzilla/>
2013-10-30 15:04 ` [Bug libstdc++/58876] No non-virtual-dtor warning in std::unique_ptr redi at gcc dot gnu.org
@ 2013-10-30 17:57 ` paolo.carlini at oracle dot com
2013-10-30 18:00 ` redi at gcc dot gnu.org
` (12 subsequent siblings)
14 siblings, 0 replies; 15+ messages in thread
From: paolo.carlini at oracle dot com @ 2013-10-30 17:57 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58876
--- Comment #3 from Paolo Carlini <paolo.carlini at oracle dot com> ---
At some point Ian Taylor filed a Bugzilla about these issues, I think it's
still open. Not sure what we should do in this area...
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug libstdc++/58876] No non-virtual-dtor warning in std::unique_ptr
[not found] <bug-58876-4@http.gcc.gnu.org/bugzilla/>
2013-10-30 15:04 ` [Bug libstdc++/58876] No non-virtual-dtor warning in std::unique_ptr redi at gcc dot gnu.org
2013-10-30 17:57 ` paolo.carlini at oracle dot com
@ 2013-10-30 18:00 ` redi at gcc dot gnu.org
2013-10-30 18:00 ` redi at gcc dot gnu.org
` (11 subsequent siblings)
14 siblings, 0 replies; 15+ messages in thread
From: redi at gcc dot gnu.org @ 2013-10-30 18:00 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58876
--- Comment #4 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Yes, I should dig Ian's bug out and have another look. I'm planning to throw
some ideas around on the mailing list ...
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug libstdc++/58876] No non-virtual-dtor warning in std::unique_ptr
[not found] <bug-58876-4@http.gcc.gnu.org/bugzilla/>
` (2 preceding siblings ...)
2013-10-30 18:00 ` redi at gcc dot gnu.org
@ 2013-10-30 18:00 ` redi at gcc dot gnu.org
2014-06-25 9:28 ` redi at gcc dot gnu.org
` (10 subsequent siblings)
14 siblings, 0 replies; 15+ messages in thread
From: redi at gcc dot gnu.org @ 2013-10-30 18:00 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58876
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |ASSIGNED
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug libstdc++/58876] No non-virtual-dtor warning in std::unique_ptr
[not found] <bug-58876-4@http.gcc.gnu.org/bugzilla/>
` (3 preceding siblings ...)
2013-10-30 18:00 ` redi at gcc dot gnu.org
@ 2014-06-25 9:28 ` redi at gcc dot gnu.org
2014-12-23 23:43 ` mw_triad at users dot sourceforge.net
` (9 subsequent siblings)
14 siblings, 0 replies; 15+ messages in thread
From: redi at gcc dot gnu.org @ 2014-06-25 9:28 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58876
Bug 58876 depends on bug 61600, which changed state.
Bug 61600 Summary: #pragma GCC diagnostic pop leaves warnings enabled
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61600
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution|--- |DUPLICATE
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug libstdc++/58876] No non-virtual-dtor warning in std::unique_ptr
[not found] <bug-58876-4@http.gcc.gnu.org/bugzilla/>
` (4 preceding siblings ...)
2014-06-25 9:28 ` redi at gcc dot gnu.org
@ 2014-12-23 23:43 ` mw_triad at users dot sourceforge.net
2014-12-24 9:01 ` redi at gcc dot gnu.org
` (8 subsequent siblings)
14 siblings, 0 replies; 15+ messages in thread
From: mw_triad at users dot sourceforge.net @ 2014-12-23 23:43 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58876
Matthew Woehlke <mw_triad at users dot sourceforge.net> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |mw_triad at users dot sourceforge.
| |net
--- Comment #5 from Matthew Woehlke <mw_triad at users dot sourceforge.net> ---
See also bug 64399, which proposes that a) the conversion itself should
generate a warning, and b) the presence of other virtual methods in A should
not be required for the warning to trip. (This could be achieved by something
like static_assert except to emit a warning, combined with
std::has_virtual_destructor, without otherwise having to fiddle with pragmas.)
Actually, this may be required for 'make_unique<A>(new B)' to warn, since the
conversion of a B* ('new B') to an A* (which is what is passed to make_unique /
unique_ptr::unique_ptr) should not warn. (IOW, unique_ptr / make_unique would
need overloads taking any pointer type and doing the conversion inside STL so
that std::has_virtual_destructor can be checked against the actual pointer
type.)
...or alternatively gcc would need to detect when a converted pointer is passed
to unique_ptr / make_unique, which seems like it would be harder.
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug libstdc++/58876] No non-virtual-dtor warning in std::unique_ptr
[not found] <bug-58876-4@http.gcc.gnu.org/bugzilla/>
` (5 preceding siblings ...)
2014-12-23 23:43 ` mw_triad at users dot sourceforge.net
@ 2014-12-24 9:01 ` redi at gcc dot gnu.org
2014-12-24 16:59 ` mw_triad at users dot sourceforge.net
` (7 subsequent siblings)
14 siblings, 0 replies; 15+ messages in thread
From: redi at gcc dot gnu.org @ 2014-12-24 9:01 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58876
--- Comment #6 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Matthew Woehlke from comment #5)
> Actually, this may be required for 'make_unique<A>(new B)' to warn, since
That's not how make_unique works.
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug libstdc++/58876] No non-virtual-dtor warning in std::unique_ptr
[not found] <bug-58876-4@http.gcc.gnu.org/bugzilla/>
` (6 preceding siblings ...)
2014-12-24 9:01 ` redi at gcc dot gnu.org
@ 2014-12-24 16:59 ` mw_triad at users dot sourceforge.net
2014-12-24 20:08 ` redi at gcc dot gnu.org
` (6 subsequent siblings)
14 siblings, 0 replies; 15+ messages in thread
From: mw_triad at users dot sourceforge.net @ 2014-12-24 16:59 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58876
--- Comment #7 from Matthew Woehlke <mw_triad at users dot sourceforge.net> ---
(In reply to Jonathan Wakely from comment #6)
> (In reply to Matthew Woehlke from comment #5)
> > Actually, this may be required for 'make_unique<A>(new B)' to warn, since
>
> That's not how make_unique works.
...and I'm suggesting it *should* be. (How else are you going to warn? After
that executes, the pointer no longer knows that it really contains a B, unless
you teach the compiler some fancy extra tricks, which seems overly complicated.
Conversely, I feel that 'make_unique<A>(new B)' should warn if it's going to
result in failing to call B's dtor. I might even go so far as to say 'even if
the compiler can prove that B's dtor is trivial', though I'd be willing to
delegate that to a different and more pedantic warning.)
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug libstdc++/58876] No non-virtual-dtor warning in std::unique_ptr
[not found] <bug-58876-4@http.gcc.gnu.org/bugzilla/>
` (7 preceding siblings ...)
2014-12-24 16:59 ` mw_triad at users dot sourceforge.net
@ 2014-12-24 20:08 ` redi at gcc dot gnu.org
2014-12-26 16:31 ` mw_triad at users dot sourceforge.net
` (5 subsequent siblings)
14 siblings, 0 replies; 15+ messages in thread
From: redi at gcc dot gnu.org @ 2014-12-24 20:08 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58876
--- Comment #8 from Jonathan Wakely <redi at gcc dot gnu.org> ---
No, really, that's not how make_unique works. You do not use 'new' with
make_unique, that's the whole point, so you would say make_unique<B>() to
create a B. Your motivating examples should be valid C++ of you want to
convince anyone, so maybe:
unique_ptr<A> p = make_unique<B>();
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug libstdc++/58876] No non-virtual-dtor warning in std::unique_ptr
[not found] <bug-58876-4@http.gcc.gnu.org/bugzilla/>
` (8 preceding siblings ...)
2014-12-24 20:08 ` redi at gcc dot gnu.org
@ 2014-12-26 16:31 ` mw_triad at users dot sourceforge.net
2021-04-17 10:23 ` db0451 at gmail dot com
` (4 subsequent siblings)
14 siblings, 0 replies; 15+ messages in thread
From: mw_triad at users dot sourceforge.net @ 2014-12-26 16:31 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58876
--- Comment #9 from Matthew Woehlke <mw_triad at users dot sourceforge.net> ---
(In reply to Jonathan Wakely from comment #8)
> No, really, that's not how make_unique works. You do not use 'new' with
> make_unique, that's the whole point [...]
D'oh, sorry :-). Not sure what I was thinking. I think I meant
'unique_ptr<A>(new B)', like to the original example. That said...
> unique_ptr<A> p = make_unique<B>();
...this is also a good example that I would like to see warn. (I think this has
the same problems; the warning would need to trigger in the conversion
operator, otherwise the knowledge of the true type is lost by the time the
unique_ptr<A> is destroyed.)
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug libstdc++/58876] No non-virtual-dtor warning in std::unique_ptr
[not found] <bug-58876-4@http.gcc.gnu.org/bugzilla/>
` (9 preceding siblings ...)
2014-12-26 16:31 ` mw_triad at users dot sourceforge.net
@ 2021-04-17 10:23 ` db0451 at gmail dot com
2021-04-19 10:40 ` redi at gcc dot gnu.org
` (3 subsequent siblings)
14 siblings, 0 replies; 15+ messages in thread
From: db0451 at gmail dot com @ 2021-04-17 10:23 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58876
DB <db0451 at gmail dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |db0451 at gmail dot com
--- Comment #10 from DB <db0451 at gmail dot com> ---
Sorry to pester, but is this likely to get anywhere, any time soon? I fixed a
bug in one of my projects recently by using AddressSanitizer, which this
would've caught if it warned on non-polymorphic deletion via unique_ptr<base>,
so it'd be nice to see.
I presume the same goes for std::shared_ptr, too.
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug libstdc++/58876] No non-virtual-dtor warning in std::unique_ptr
[not found] <bug-58876-4@http.gcc.gnu.org/bugzilla/>
` (10 preceding siblings ...)
2021-04-17 10:23 ` db0451 at gmail dot com
@ 2021-04-19 10:40 ` redi at gcc dot gnu.org
2021-08-31 18:20 ` redi at gcc dot gnu.org
` (2 subsequent siblings)
14 siblings, 0 replies; 15+ messages in thread
From: redi at gcc dot gnu.org @ 2021-04-19 10:40 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58876
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |NEW
Assignee|redi at gcc dot gnu.org |unassigned at gcc dot gnu.org
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug libstdc++/58876] No non-virtual-dtor warning in std::unique_ptr
[not found] <bug-58876-4@http.gcc.gnu.org/bugzilla/>
` (11 preceding siblings ...)
2021-04-19 10:40 ` redi at gcc dot gnu.org
@ 2021-08-31 18:20 ` redi at gcc dot gnu.org
2021-08-31 20:09 ` harald at gigawatt dot nl
2021-09-01 9:57 ` redi at gcc dot gnu.org
14 siblings, 0 replies; 15+ messages in thread
From: redi at gcc dot gnu.org @ 2021-08-31 18:20 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58876
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
See Also| |https://gcc.gnu.org/bugzill
| |a/show_bug.cgi?id=64399
--- Comment #11 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to DB from comment #10)
> Sorry to pester, but is this likely to get anywhere, any time soon?
No, probably not. Comment 2 doesn't work because -Wsystem-headers can't be
enabled and disabled using pragmas. It doesn't work like other warnings.
I don't think this can be fixed in the library.
> I presume the same goes for std::shared_ptr, too.
No, because shared_ptr type-erases the deleter and so deletes the dynamic type
even if the stored pointer is upcast to a different static type.
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug libstdc++/58876] No non-virtual-dtor warning in std::unique_ptr
[not found] <bug-58876-4@http.gcc.gnu.org/bugzilla/>
` (12 preceding siblings ...)
2021-08-31 18:20 ` redi at gcc dot gnu.org
@ 2021-08-31 20:09 ` harald at gigawatt dot nl
2021-09-01 9:57 ` redi at gcc dot gnu.org
14 siblings, 0 replies; 15+ messages in thread
From: harald at gigawatt dot nl @ 2021-08-31 20:09 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58876
Harald van Dijk <harald at gigawatt dot nl> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |harald at gigawatt dot nl
--- Comment #12 from Harald van Dijk <harald at gigawatt dot nl> ---
(In reply to Jonathan Wakely from comment #11)
> No, probably not. Comment 2 doesn't work because -Wsystem-headers can't be
> enabled and disabled using pragmas. It doesn't work like other warnings.
However, the internal version of the #line directive, # [line number] [file
name] [flags] could be used to mark a region of a system header as non-system
header, which should achieve the same result, right? It might need a bit of
cleanup to be maintainable, but this seems to work as a proof of concept:
--- bits/unique_ptr.h
+++ bits/unique_ptr.h
@@ -82,7 +82,9 @@
"can't delete pointer to incomplete type");
static_assert(sizeof(_Tp)>0,
"can't delete pointer to incomplete type");
+# 86 __FILE__
delete __ptr;
+# 88 __FILE__ 3
}
};
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug libstdc++/58876] No non-virtual-dtor warning in std::unique_ptr
[not found] <bug-58876-4@http.gcc.gnu.org/bugzilla/>
` (13 preceding siblings ...)
2021-08-31 20:09 ` harald at gigawatt dot nl
@ 2021-09-01 9:57 ` redi at gcc dot gnu.org
14 siblings, 0 replies; 15+ messages in thread
From: redi at gcc dot gnu.org @ 2021-09-01 9:57 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58876
--- Comment #13 from Jonathan Wakely <redi at gcc dot gnu.org> ---
It's so crazy, it just might work.
^ permalink raw reply [flat|nested] 15+ messages in thread
end of thread, other threads:[~2021-09-01 9:57 UTC | newest]
Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <bug-58876-4@http.gcc.gnu.org/bugzilla/>
2013-10-30 15:04 ` [Bug libstdc++/58876] No non-virtual-dtor warning in std::unique_ptr redi at gcc dot gnu.org
2013-10-30 17:57 ` paolo.carlini at oracle dot com
2013-10-30 18:00 ` redi at gcc dot gnu.org
2013-10-30 18:00 ` redi at gcc dot gnu.org
2014-06-25 9:28 ` redi at gcc dot gnu.org
2014-12-23 23:43 ` mw_triad at users dot sourceforge.net
2014-12-24 9:01 ` redi at gcc dot gnu.org
2014-12-24 16:59 ` mw_triad at users dot sourceforge.net
2014-12-24 20:08 ` redi at gcc dot gnu.org
2014-12-26 16:31 ` mw_triad at users dot sourceforge.net
2021-04-17 10:23 ` db0451 at gmail dot com
2021-04-19 10:40 ` redi at gcc dot gnu.org
2021-08-31 18:20 ` redi at gcc dot gnu.org
2021-08-31 20:09 ` harald at gigawatt dot nl
2021-09-01 9:57 ` 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).