[Bug libstdc++/58876] No non-virtual-dtor warning in std::unique_ptr

2021-09-01 Thread redi at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58876

--- Comment #13 from Jonathan Wakely  ---
It's so crazy, it just might work.

[Bug libstdc++/58876] No non-virtual-dtor warning in std::unique_ptr

2021-08-31 Thread harald at gigawatt dot nl via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58876

Harald van Dijk  changed:

   What|Removed |Added

 CC||harald at gigawatt dot nl

--- Comment #12 from Harald van Dijk  ---
(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
   }
 };

[Bug libstdc++/58876] No non-virtual-dtor warning in std::unique_ptr

2021-08-31 Thread redi at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58876

Jonathan Wakely  changed:

   What|Removed |Added

   See Also||https://gcc.gnu.org/bugzill
   ||a/show_bug.cgi?id=64399

--- Comment #11 from Jonathan Wakely  ---
(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.

[Bug libstdc++/58876] No non-virtual-dtor warning in std::unique_ptr

2021-04-19 Thread redi at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58876

Jonathan Wakely  changed:

   What|Removed |Added

 Status|ASSIGNED|NEW
   Assignee|redi at gcc dot gnu.org|unassigned at gcc dot 
gnu.org

[Bug libstdc++/58876] No non-virtual-dtor warning in std::unique_ptr

2021-04-17 Thread db0451 at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58876

DB  changed:

   What|Removed |Added

 CC||db0451 at gmail dot com

--- Comment #10 from DB  ---
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,
so it'd be nice to see.

I presume the same goes for std::shared_ptr, too.

[Bug libstdc++/58876] No non-virtual-dtor warning in std::unique_ptr

2014-12-26 Thread mw_triad at users dot sourceforge.net
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_ptrA(new B)', like to the original example. That said...

 unique_ptrA p = make_uniqueB();

...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_ptrA is destroyed.)


[Bug libstdc++/58876] No non-virtual-dtor warning in std::unique_ptr

2014-12-24 Thread redi at gcc dot gnu.org
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_uniqueA(new B)' to warn, since

That's not how make_unique works.


[Bug libstdc++/58876] No non-virtual-dtor warning in std::unique_ptr

2014-12-24 Thread mw_triad at users dot sourceforge.net
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_uniqueA(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_uniqueA(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.)


[Bug libstdc++/58876] No non-virtual-dtor warning in std::unique_ptr

2014-12-24 Thread redi at gcc dot gnu.org
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_uniqueB() to
create a B. Your motivating examples should be valid C++ of you want to
convince anyone, so maybe:

unique_ptrA p = make_uniqueB();


[Bug libstdc++/58876] No non-virtual-dtor warning in std::unique_ptr

2014-12-23 Thread mw_triad at users dot sourceforge.net
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_uniqueA(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.


[Bug libstdc++/58876] No non-virtual-dtor warning in std::unique_ptr

2014-08-20 Thread manu at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58876
Bug 58876 depends on bug 59304, which changed state.

Bug 59304 Summary: #pragma diagnostic pop after warning fails for options 
unspecified in the command-line and disabled by default
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=59304

   What|Removed |Added

 Status|NEW |RESOLVED
 Resolution|--- |FIXED


[Bug libstdc++/58876] No non-virtual-dtor warning in std::unique_ptr

2014-06-25 Thread redi at gcc dot gnu.org
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


[Bug libstdc++/58876] No non-virtual-dtor warning in std::unique_ptr

2013-10-30 Thread redi at gcc dot gnu.org
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.


[Bug libstdc++/58876] No non-virtual-dtor warning in std::unique_ptr

2013-10-30 Thread redi at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58876

Jonathan Wakely redi at gcc dot gnu.org changed:

   What|Removed |Added

   Assignee|unassigned at gcc dot gnu.org  |redi at gcc dot gnu.org

--- Comment #2 from Jonathan Wakely redi at gcc dot gnu.org ---
Actually we can use this around the definition of default_delete

#pragma GCC diagnostic push
#pragma GCC diagnostic warning -Wsystem-headers
  /// Primary template of default_delete, used by unique_ptr
  templatetypename _Tp
struct default_delete
{
...
};
#pragma GCC diagnostic pop


[Bug libstdc++/58876] No non-virtual-dtor warning in std::unique_ptr

2013-10-30 Thread paolo.carlini at oracle dot com
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...


[Bug libstdc++/58876] No non-virtual-dtor warning in std::unique_ptr

2013-10-30 Thread redi at gcc dot gnu.org
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


[Bug libstdc++/58876] No non-virtual-dtor warning in std::unique_ptr

2013-10-30 Thread redi at gcc dot gnu.org
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 ...