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

            Bug ID: 106604
           Summary: Fully-specified deduction guide in anonymous namespace
                    warns as-if a function? Unsuppressably?
           Product: gcc
           Version: 13.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: nabijaczleweli at nabijaczleweli dot xyz
  Target Milestone: ---

Reproduced this separately on 10.2.1-6 (bullseye), 12.1.0-7 (sid from 2 weeks
ago), trunk (according to godbolt).

TL;DR: https://gcc.godbolt.org/z/869TdbvEe


Given:
  namespace {
      template <class T>
      struct test {
          test(T) noexcept {}
      };

      UNUSED test(bool) -> test<bool>;
  }

If UNUSED is blank, GCC produces:
  <source>:7:12: warning: '{anonymous}::test(int) -> test<int>' declared
'static' but never defined [-Wunused-function]
      7 |     UNUSED test(int) -> test<int>;
        |            ^~~~
  Compiler returned: 0


If UNUSED is [[maybe_unused]] (which was my solution originally since it works
on Clang):
  <source>:0:16: error: 'decl-specifier' in declaration of deduction guide
      0 | #define UNUSED [[maybe_unused]]
        |                ^
  <source>:7:5: note: in expansion of macro 'UNUSED'
      7 |     UNUSED test(int) -> test<int>;
        |     ^~~~~~
  <source>:7:12: warning: '{anonymous}::test(int) -> test<int>' declared
'static' but never defined [-Wunused-function]
      7 |     UNUSED test(int) -> test<int>;
        |            ^~~~
  Compiler returned: 1


So:
  * the deduction guide is decidedly not "declared 'static'" (anon namespace
means it has static linkage, sure, but it's not 'static')
  * of course it's not defined?? can you even define a deduction guide?
  * how do you suppress this? (besides template<class = void>)?
  • [Bug c++/106604] New... nabijaczleweli at nabijaczleweli dot xyz via Gcc-bugs

Reply via email to