public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/102283] New: Inconsistent/wrong overload resolution when using an initializer list and a defaulted template parameter
@ 2021-09-10 19:06 dangelog at gmail dot com
  2021-09-15 16:16 ` [Bug c++/102283] " ppalka at gcc dot gnu.org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: dangelog at gmail dot com @ 2021-09-10 19:06 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 102283
           Summary: Inconsistent/wrong overload resolution when using an
                    initializer list and a defaulted template parameter
           Product: gcc
           Version: 11.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: dangelog at gmail dot com
  Target Milestone: ---

Hello,

The following testcase has an "inconsistent" overload resolution:


template <typename U>
struct helper {};

struct data {};

template <typename T, typename E>
struct S 
{
    template <typename T2=T>
    void f(T2 &&); // #1

    template <typename E2=E>
    void f(const helper<E2> &); // #2
};

int main() {
    S<int, int> s1;
    S<data, int> s2;
    s1.f({});
    s2.f({});
}


https://gcc.godbolt.org/z/nsj48M7af


On GCC 11, the the first call to f() resolves to #1, but the second call
resolves to #2. I cannot find any reason for this inconsistency in the ranking
of the overloads; no warnings are emitted under -Wall -Wextra. 

Clang and MSVC both always call #1.

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

end of thread, other threads:[~2021-10-12 13:47 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-10 19:06 [Bug c++/102283] New: Inconsistent/wrong overload resolution when using an initializer list and a defaulted template parameter dangelog at gmail dot com
2021-09-15 16:16 ` [Bug c++/102283] " ppalka at gcc dot gnu.org
2021-09-15 20:29 ` dangelog at gmail dot com
2021-09-16 13:40 ` ppalka at gcc dot gnu.org
2021-09-16 17:46 ` jason at gcc dot gnu.org
2021-10-01 17:30 ` dangelog at gmail dot com
2021-10-12 13:40 ` ppalka at gcc dot gnu.org
2021-10-12 13:47 ` 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).