public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/106604] New: Fully-specified deduction guide in anonymous namespace warns as-if a function? Unsuppressably?
@ 2022-08-13  0:17 nabijaczleweli at nabijaczleweli dot xyz
  2022-08-14 19:36 ` [Bug c++/106604] " pinskia at gcc dot gnu.org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: nabijaczleweli at nabijaczleweli dot xyz @ 2022-08-13  0:17 UTC (permalink / raw)
  To: gcc-bugs

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>)?

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug c++/106604] Fully-specified deduction guide in anonymous namespace warns as-if a function? Unsuppressably?
  2022-08-13  0:17 [Bug c++/106604] New: Fully-specified deduction guide in anonymous namespace warns as-if a function? Unsuppressably? nabijaczleweli at nabijaczleweli dot xyz
@ 2022-08-14 19:36 ` pinskia at gcc dot gnu.org
  2023-05-19  4:19 ` pinskia at gcc dot gnu.org
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-08-14 19:36 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
     Ever confirmed|0                           |1
   Last reconfirmed|                            |2022-08-14
             Status|UNCONFIRMED                 |NEW
      Known to fail|                            |7.1.0

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Confirmed.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug c++/106604] Fully-specified deduction guide in anonymous namespace warns as-if a function? Unsuppressably?
  2022-08-13  0:17 [Bug c++/106604] New: Fully-specified deduction guide in anonymous namespace warns as-if a function? Unsuppressably? nabijaczleweli at nabijaczleweli dot xyz
  2022-08-14 19:36 ` [Bug c++/106604] " pinskia at gcc dot gnu.org
@ 2023-05-19  4:19 ` pinskia at gcc dot gnu.org
  2023-08-12  1:13 ` cvs-commit at gcc dot gnu.org
  2023-08-15 13:19 ` ppalka at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-05-19  4:19 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |development at jordi dot vilar.cat

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
*** Bug 107587 has been marked as a duplicate of this bug. ***

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug c++/106604] Fully-specified deduction guide in anonymous namespace warns as-if a function? Unsuppressably?
  2022-08-13  0:17 [Bug c++/106604] New: Fully-specified deduction guide in anonymous namespace warns as-if a function? Unsuppressably? nabijaczleweli at nabijaczleweli dot xyz
  2022-08-14 19:36 ` [Bug c++/106604] " pinskia at gcc dot gnu.org
  2023-05-19  4:19 ` pinskia at gcc dot gnu.org
@ 2023-08-12  1:13 ` cvs-commit at gcc dot gnu.org
  2023-08-15 13:19 ` ppalka at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-08-12  1:13 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Patrick Palka <ppalka@gcc.gnu.org>:

https://gcc.gnu.org/g:f50f603cbfd05653555e9856360c83108bbd1d8a

commit r14-3175-gf50f603cbfd05653555e9856360c83108bbd1d8a
Author: Patrick Palka <ppalka@redhat.com>
Date:   Fri Aug 11 21:13:23 2023 -0400

    c++: bogus warning w/ deduction guide in anon ns [PR106604]

    Here we're unintentionally issuing a "declared static but never defined"
    warning from wrapup_namespace_globals for a deduction guide declared in
    an anonymous namespace.  This patch fixes this by giving deduction guides
    a dummy DECL_INITIAL, which suppresses the warning and also allows us to
    simplify redeclaration checking for them.

    Co-authored-by: Jason Merrill <jason@redhat.com>

            PR c++/106604

    gcc/cp/ChangeLog:

            * decl.cc (redeclaration_error_message): Remove special handling
            for deduction guides.
            (grokfndecl): Give deduction guides a dummy DECL_INITIAL.

    gcc/testsuite/ChangeLog:

            * g++.dg/cpp1z/class-deduction74.C: Expect "defined" instead
            of "declared" in the repeated deduction guide diagnostics.
            * g++.dg/cpp1z/class-deduction116.C: New test.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug c++/106604] Fully-specified deduction guide in anonymous namespace warns as-if a function? Unsuppressably?
  2022-08-13  0:17 [Bug c++/106604] New: Fully-specified deduction guide in anonymous namespace warns as-if a function? Unsuppressably? nabijaczleweli at nabijaczleweli dot xyz
                   ` (2 preceding siblings ...)
  2023-08-12  1:13 ` cvs-commit at gcc dot gnu.org
@ 2023-08-15 13:19 ` ppalka at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: ppalka at gcc dot gnu.org @ 2023-08-15 13:19 UTC (permalink / raw)
  To: gcc-bugs

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

Patrick Palka <ppalka at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ppalka at gcc dot gnu.org
   Target Milestone|---                         |14.0
         Resolution|---                         |FIXED
             Status|NEW                         |RESOLVED

--- Comment #4 from Patrick Palka <ppalka at gcc dot gnu.org> ---
Fixed for GCC 14.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2023-08-15 13:19 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-13  0:17 [Bug c++/106604] New: Fully-specified deduction guide in anonymous namespace warns as-if a function? Unsuppressably? nabijaczleweli at nabijaczleweli dot xyz
2022-08-14 19:36 ` [Bug c++/106604] " pinskia at gcc dot gnu.org
2023-05-19  4:19 ` pinskia at gcc dot gnu.org
2023-08-12  1:13 ` cvs-commit at gcc dot gnu.org
2023-08-15 13:19 ` ppalka at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).