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

--- Comment #6 from Mikael Morin <mikael at gcc dot gnu.org> ---
Created attachment 54598
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=54598&action=edit
Tentative patch

Indeed the namespaces created during module loading are not stored anywhere, so
they are leaked basically.  As they are the pieces holding symbols, which
themselves hold other things, etc, all these are leaked as well.

The attached patch stores in the current namespace a tree of module namespaces,
and use those namespaces when loading a symbol from a module.  For a symbol
that is present in a module, this means that its sym->ns will be the module
namespace, even if its sym->ns was not the module namespace at the time it was
written.  This makes a difference for symbols that are present in more than one
namespace, but I'm not sure how important that difference is.

This seems to work on the reduced testcases, can't fully test right now.

Reply via email to