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

            Bug ID: 122636
           Summary: False positive warning 'expose TU-local entity'
           Product: gcc
           Version: 16.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: d7d1cd at mail dot ru
  Target Milestone: ---

Here's the module code:
  export module M;
  export template <typename>
  struct Foo {
    constexpr static inline auto lambda = []{};
    template <typename T = decltype(lambda)>
    static void foo(T = lambda) {}
  };

And here's the code that imports this module:
  import M;
  namespace {
    struct Bar {};
    void bar() { Foo<Bar>::foo(); }
  }

  int main() { bar(); }

When compiling, I get a warning:
main.cc:7:17:
7 | Foo<Bar>::foo();
module.ixx:8:18: warning: instantiation exposes TU-local entity
'Foo@M<{anonymous}::Bar>::lambda' [-Wexpose-global-module-tu-local]
8 | static void foo(T = lambda) {}
module.ixx:5:34: note: declared here
5 | constexpr static inline auto lambda = []{};

This appears to be a regression, as it only appears in version 16. There is no
warning in versions 14.1-15.2.
Here is a reproduction of the error: https://godbolt.org/z/EesKrz8v1

Reply via email to