public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/100963] New: GCC 11 regression: templated constructor with std::initializer_list<T> is not selected
@ 2021-06-08 11:06 j.l.k at gmx dot com
  2021-06-08 11:12 ` [Bug c++/100963] [11/12 Regression] " rguenth at gcc dot gnu.org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: j.l.k at gmx dot com @ 2021-06-08 11:06 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 100963
           Summary: GCC 11 regression: templated constructor with
                    std::initializer_list<T> is not selected
           Product: gcc
           Version: 11.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: j.l.k at gmx dot com
  Target Milestone: ---

Consider the following program (preprocessed source is attached):

```
#include <iostream>

struct A
{
    explicit A(int)
    {
        std::cout << "A(int) constructor called" << std::endl;
    }

    A(std::initializer_list<int>)
    {
        std::cout << "A's constructor with initializer_list called" <<
std::endl;
    }
};

struct B
{
    explicit B(int)
    {
        std::cout << "B(int) constructor called" << std::endl;
    }

    template<typename T>
    B(std::initializer_list<T>)
    {
        std::cout << "B's constructor with initializer_list called" <<
std::endl;
    }
};

int main()
{
    A({0});
    B({0});
}
```

When compiled with GCC 11 (`g++ -std=c++14
gcc11_initializer_list_constructor.cpp -o gcc11_initializer_list_constructor`),
the program gives the following output:

A's constructor with initializer_list called
B(int) constructor called

Whereas with GCC 10 it produced this as expected:

A's constructor with initializer_list called
B's constructor with initializer_list called

Tested with GCC 11.1.0 from Arch Linux, the PKGBUILD is located here: 
https://github.com/archlinux/svntogit-packages/blob/92c91ef891e9e2ed48f7f75921eb6321a2c7947d/trunk/PKGBUILD

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

end of thread, other threads:[~2021-06-08 17:35 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-08 11:06 [Bug c++/100963] New: GCC 11 regression: templated constructor with std::initializer_list<T> is not selected j.l.k at gmx dot com
2021-06-08 11:12 ` [Bug c++/100963] [11/12 Regression] " rguenth at gcc dot gnu.org
2021-06-08 11:15 ` j.l.k at gmx dot com
2021-06-08 12:39 ` ppalka at gcc dot gnu.org
2021-06-08 13:11 ` jason at gcc dot gnu.org
2021-06-08 17:28 ` cvs-commit at gcc dot gnu.org
2021-06-08 17:29 ` cvs-commit at gcc dot gnu.org
2021-06-08 17:35 ` jason 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).