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

            Bug ID: 125778
           Summary: [modules] template class method with separate
                    definition cannot be used
           Product: gcc
           Version: 16.1.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: marcel at laverdet dot com
  Target Milestone: ---

// a.cc
export module ns:foo;

struct foo {
  static auto get();
};

// b.cc
export module ns:foo_impl;
import :foo;

auto foo::get() { return 0; }

// c.cc
export module ns;
export import :foo;
export import :foo_impl;

// d.cc
module ns;
import :foo_impl;

int bar() {
  return foo::get();
}

---

$ /root/gcc-16/bin/g++ -std=c++26 -Wall -fmodules -c a.cc
$ /root/gcc-16/bin/g++ -std=c++26 -Wall -fmodules -c b.cc
$ /root/gcc-16/bin/g++ -std=c++26 -Wall -fmodules -c c.cc
$ /root/gcc-16/bin/g++ -std=c++26 -Wall -fmodules -c d.cc
d.cc: In function ‘int bar()’:
d.cc:5:24: error: use of ‘static auto foo@ns:foo::get()’ before deduction of
‘auto’
    5 |         return foo::get();
      |                ~~~~~~~~^~

---

It works if `get()` is converted to a free function. It doesn't appear to be a
regression because gcc-15 fails in the same manner.

Compiling from releases/gcc-16 @ 1997e95e4e

Reply via email to