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
* [Bug c++/100963] [11/12 Regression] GCC 11 regression: templated constructor with std::initializer_list<T> is not selected
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 ` rguenth at gcc dot gnu.org
2021-06-08 11:15 ` j.l.k at gmx dot com
` (5 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-06-08 11:12 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100963
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |wrong-code
Target Milestone|--- |11.2
Summary|GCC 11 regression: |[11/12 Regression] GCC 11
|templated constructor with |regression: templated
|std::initializer_list<T> is |constructor with
|not selected |std::initializer_list<T> is
| |not selected
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/100963] [11/12 Regression] GCC 11 regression: templated constructor with std::initializer_list<T> is not selected
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
` (4 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: j.l.k at gmx dot com @ 2021-06-08 11:15 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100963
Jakub Klinkovský <j.l.k at gmx dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |j.l.k at gmx dot com
--- Comment #1 from Jakub Klinkovský <j.l.k at gmx dot com> ---
Created attachment 50962
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=50962&action=edit
preprocessed file for the test case
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/100963] [11/12 Regression] GCC 11 regression: templated constructor with std::initializer_list<T> is not selected
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
` (3 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: ppalka at gcc dot gnu.org @ 2021-06-08 12:39 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100963
Patrick Palka <ppalka at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Ever confirmed|0 |1
Status|UNCONFIRMED |NEW
Known to work| |10.3.0, 9.4.0
Known to fail| |11.1.0
CC| |jason at gcc dot gnu.org,
| |ppalka at gcc dot gnu.org
Last reconfirmed| |2021-06-08
--- Comment #2 from Patrick Palka <ppalka at gcc dot gnu.org> ---
Confirmed, started with r11-7289.
Reduced:
#include <initializer_list>
struct B {
B(int) = delete;
template<class T> B(std::initializer_list<T>);
};
int main() {
B({0});
}
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/100963] [11/12 Regression] GCC 11 regression: templated constructor with std::initializer_list<T> is not selected
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
` (2 preceding siblings ...)
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
` (2 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: jason at gcc dot gnu.org @ 2021-06-08 13:11 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100963
Jason Merrill <jason at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Assignee|unassigned at gcc dot gnu.org |jason at gcc dot gnu.org
Status|NEW |ASSIGNED
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/100963] [11/12 Regression] GCC 11 regression: templated constructor with std::initializer_list<T> is not selected
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
` (3 preceding siblings ...)
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
6 siblings, 0 replies; 8+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-06-08 17:28 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100963
--- Comment #3 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jason Merrill <jason@gcc.gnu.org>:
https://gcc.gnu.org/g:91349e57bbfd010156b9128b2ad751c8843e7245
commit r12-1299-g91349e57bbfd010156b9128b2ad751c8843e7245
Author: Jason Merrill <jason@redhat.com>
Date: Tue Jun 8 09:19:58 2021 -0400
c++: braced-list overload resolution [PR100963]
My PR969626 patch made us ignore template candidates when there's a perfect
non-template candidate. In this case, we were considering B(int) a perfect
match for B({0}), but the brace elision makes it imperfect.
PR c++/100963
gcc/cp/ChangeLog:
* call.c (perfect_conversion_p): Check check_narrowing.
gcc/testsuite/ChangeLog:
* g++.dg/cpp0x/initlist124.C: New test.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/100963] [11/12 Regression] GCC 11 regression: templated constructor with std::initializer_list<T> is not selected
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
` (4 preceding siblings ...)
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
6 siblings, 0 replies; 8+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-06-08 17:29 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100963
--- Comment #4 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-11 branch has been updated by Jason Merrill
<jason@gcc.gnu.org>:
https://gcc.gnu.org/g:5af06ce836d4d8d1654db3855db8b86a994faf49
commit r11-8526-g5af06ce836d4d8d1654db3855db8b86a994faf49
Author: Jason Merrill <jason@redhat.com>
Date: Tue Jun 8 09:19:58 2021 -0400
c++: braced-list overload resolution [PR100963]
My PR969626 patch made us ignore template candidates when there's a perfect
non-template candidate. In this case, we were considering B(int) a perfect
match for B({0}), but the brace elision makes it imperfect.
PR c++/100963
gcc/cp/ChangeLog:
* call.c (perfect_conversion_p): Check check_narrowing.
gcc/testsuite/ChangeLog:
* g++.dg/cpp0x/initlist124.C: New test.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/100963] [11/12 Regression] GCC 11 regression: templated constructor with std::initializer_list<T> is not selected
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
` (5 preceding siblings ...)
2021-06-08 17:29 ` cvs-commit at gcc dot gnu.org
@ 2021-06-08 17:35 ` jason at gcc dot gnu.org
6 siblings, 0 replies; 8+ messages in thread
From: jason at gcc dot gnu.org @ 2021-06-08 17:35 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100963
Jason Merrill <jason at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|--- |FIXED
Status|ASSIGNED |RESOLVED
--- Comment #5 from Jason Merrill <jason at gcc dot gnu.org> ---
Fixed for 11.2/12.
^ 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).