public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/107587] New: Explicit specializations of user-defined deduction guides in unnamed namespaces trigger -Wunused-function
@ 2022-11-09  9:20 development at jordi dot vilar.cat
  2023-05-19  4:19 ` [Bug c++/107587] " pinskia at gcc dot gnu.org
  0 siblings, 1 reply; 2+ messages in thread
From: development at jordi dot vilar.cat @ 2022-11-09  9:20 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 107587
           Summary: Explicit specializations of user-defined deduction
                    guides in unnamed namespaces trigger -Wunused-function
           Product: gcc
           Version: 12.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: development at jordi dot vilar.cat
  Target Milestone: ---

After https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53711, functions in unnamed
namespace may trigger -Wunused-function.

Explicit (full) specializations of member functions don't have the `template<>`
prefix. User-defined deduction guides follow the same syntax, and maybe this
confuses the compiler as they trigger -Wunused-function when inside an unnamed
namespace, but (maybe partially specialized) templated user-defined deduction
guides, that is, those with the `template<...>` prefix, don't.

The following valid code compiles cleanly with clang (and even msvc!!!), but
triggers -Wunued-function in gcc-12 (and older) just compiling wit -Wall:

```
template<typename T> struct X { X(T) {} };
X(bool) -> X<int>;

namespace
{
    template<typename T> struct Y { Y(T) {} };
    Y(bool) -> Y<int>;
}

void test()
{
    [[maybe_unused]] X<int> x = X{false};
    [[maybe_unused]] Y<int> y = Y{false};
}
```


It is demoed in Compiler Explorer: https://godbolt.org/z/rf3zrEzsd.

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

* [Bug c++/107587] Explicit specializations of user-defined deduction guides in unnamed namespaces trigger -Wunused-function
  2022-11-09  9:20 [Bug c++/107587] New: Explicit specializations of user-defined deduction guides in unnamed namespaces trigger -Wunused-function development at jordi dot vilar.cat
@ 2023-05-19  4:19 ` pinskia at gcc dot gnu.org
  0 siblings, 0 replies; 2+ 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=107587

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|---                         |DUPLICATE

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Dup of bug 106604.

*** This bug has been marked as a duplicate of bug 106604 ***

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

end of thread, other threads:[~2023-05-19  4:19 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-09  9:20 [Bug c++/107587] New: Explicit specializations of user-defined deduction guides in unnamed namespaces trigger -Wunused-function development at jordi dot vilar.cat
2023-05-19  4:19 ` [Bug c++/107587] " pinskia 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).