https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66069

            Bug ID: 66069
           Summary: New -fkeep-all-method-instances
           Product: gcc
           Version: 6.0
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: P3
         Component: debug
          Assignee: unassigned at gcc dot gnu.org
          Reporter: jan.kratochvil at redhat dot com
  Target Milestone: ---
            Target: x86_64-linux-gnu

For debugging (-O0 -g) code there could be a way to provide all instantiable
methods for TYPE when anything from template<TYPE> gets used.  The problem:

-------------------------------------------------------------------------------
1       #include <memory>
2       class C { public: int i; };
3       int main() {
4         std::unique_ptr<C> cp(new C());
5         return cp->i;
6       }
(gdb) p cp
$1 = std::unique_ptr<C> containing 0x603010
(gdb) p *cp
Could not find operator*.
-------------------------------------------------------------------------------
compiled-in:
std::unique_ptr<C, std::default_delete<C> >::get() const
std::unique_ptr<C, std::default_delete<C> >::get_deleter()
std::unique_ptr<C, std::default_delete<C> >::operator->() const
std::unique_ptr<C, std::default_delete<C> >::unique_ptr(C*)
std::unique_ptr<C, std::default_delete<C> >::~unique_ptr()
-------------------------------------------------------------------------------

The current workaround:
-------------------------------------------------------------------------------
1       #include <memory>
2       class C { public: int i; };
3       int main() {
4         std::unique_ptr<C> cp(new C());
5         __attribute__((unused)) const C &gdbstub(*cp);
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
6         return cp->i;
7       }
(gdb) p *cp
$1 = (C &) @0x603010: {i = 0}
-------------------------------------------------------------------------------
added method:
std::unique_ptr<C, std::default_delete<C> >::operator*() const
-------------------------------------------------------------------------------

Similar problems are with operator[], operator-> for maps etc.

Reply via email to