public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/106366] New: CTAD fails to prioritize initializer_list when done via Deduction guide and inherited CTORS
@ 2022-07-20 6:35 peter.cpp at sommerlad dot ch
2022-07-20 18:17 ` [Bug c++/106366] " ppalka at gcc dot gnu.org
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: peter.cpp at sommerlad dot ch @ 2022-07-20 6:35 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106366
Bug ID: 106366
Summary: CTAD fails to prioritize initializer_list when done
via Deduction guide and inherited CTORS
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: peter.cpp at sommerlad dot ch
Target Milestone: ---
The following code fails to compile on trunk, 12.1 and all 11 versions of g++ I
tried and compiles fine with clang and msvc:
#include <vector>
template<typename T>
struct Adapter: std::vector<T>{
using std::vector<T>::vector;
// Adapter(std::initializer_list<T> l)
// :std::vector<T>::vector(l){}
};
template<typename T>
Adapter(std::initializer_list<T>) -> Adapter<T>;
int main(){
Adapter x{1,2,3};
}
see https://compiler-explorer.com/z/hj9zPPa8d
defining the constructor instead of the (not yet inherited) deduction guide
makes it work.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c++/106366] CTAD fails to prioritize initializer_list when done via Deduction guide and inherited CTORS
2022-07-20 6:35 [Bug c++/106366] New: CTAD fails to prioritize initializer_list when done via Deduction guide and inherited CTORS peter.cpp at sommerlad dot ch
@ 2022-07-20 18:17 ` ppalka at gcc dot gnu.org
2022-07-22 22:43 ` cvs-commit at gcc dot gnu.org
2022-07-22 22:44 ` ppalka at gcc dot gnu.org
2 siblings, 0 replies; 4+ messages in thread
From: ppalka at gcc dot gnu.org @ 2022-07-20 18:17 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106366
Patrick Palka <ppalka at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Ever confirmed|0 |1
Assignee|unassigned at gcc dot gnu.org |ppalka at gcc dot gnu.org
CC| |ppalka at gcc dot gnu.org
Keywords| |rejects-valid
Status|UNCONFIRMED |ASSIGNED
Last reconfirmed| |2022-07-20
--- Comment #1 from Patrick Palka <ppalka at gcc dot gnu.org> ---
Confirmed, reduced:
#include <initializer_list>
template<class T>
struct A { A(...); };
template<class T>
A(std::initializer_list<T>) -> A<T>;
A a{1,2,3};
This seems valid according to [over.match.class.deduct]/4. In order for the
initializer-list phase of overload resolution to kick in the class template
doesn't necessarily need an initializer-list constructor, it suffices to just
have a guide that looks like one.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c++/106366] CTAD fails to prioritize initializer_list when done via Deduction guide and inherited CTORS
2022-07-20 6:35 [Bug c++/106366] New: CTAD fails to prioritize initializer_list when done via Deduction guide and inherited CTORS peter.cpp at sommerlad dot ch
2022-07-20 18:17 ` [Bug c++/106366] " ppalka at gcc dot gnu.org
@ 2022-07-22 22:43 ` cvs-commit at gcc dot gnu.org
2022-07-22 22:44 ` ppalka at gcc dot gnu.org
2 siblings, 0 replies; 4+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-07-22 22:43 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106366
--- Comment #2 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:f77bbc8f86900b21abdec457b4153b30512e192d
commit r13-1805-gf77bbc8f86900b21abdec457b4153b30512e192d
Author: Patrick Palka <ppalka@redhat.com>
Date: Fri Jul 22 18:42:02 2022 -0400
c++: CTAD from initializer list [PR106366]
During CTAD, we currently perform the first phase of overload resolution
from [over.match.list] only if the class template has a list constructor.
But according to [over.match.class.deduct]/4 it should be enough to just
have a guide that looks like a list constructor (which is a more general
criterion in light of user-defined guides).
PR c++/106366
gcc/cp/ChangeLog:
* pt.cc (do_class_deduction): Don't consider TYPE_HAS_LIST_CTOR
when setting try_list_ctor. Reset args even when try_list_ctor
is true and there are no list candidates. Call resolve_args on
the reset args. Rename try_list_ctor to try_list_cand.
gcc/testsuite/ChangeLog:
* g++.dg/cpp1z/class-deduction112.C: New test.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c++/106366] CTAD fails to prioritize initializer_list when done via Deduction guide and inherited CTORS
2022-07-20 6:35 [Bug c++/106366] New: CTAD fails to prioritize initializer_list when done via Deduction guide and inherited CTORS peter.cpp at sommerlad dot ch
2022-07-20 18:17 ` [Bug c++/106366] " ppalka at gcc dot gnu.org
2022-07-22 22:43 ` cvs-commit at gcc dot gnu.org
@ 2022-07-22 22:44 ` ppalka at gcc dot gnu.org
2 siblings, 0 replies; 4+ messages in thread
From: ppalka at gcc dot gnu.org @ 2022-07-22 22:44 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106366
Patrick Palka <ppalka at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution|--- |FIXED
Target Milestone|--- |13.0
--- Comment #3 from Patrick Palka <ppalka at gcc dot gnu.org> ---
Fixed for GCC 13.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2022-07-22 22:44 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-20 6:35 [Bug c++/106366] New: CTAD fails to prioritize initializer_list when done via Deduction guide and inherited CTORS peter.cpp at sommerlad dot ch
2022-07-20 18:17 ` [Bug c++/106366] " ppalka at gcc dot gnu.org
2022-07-22 22:43 ` cvs-commit at gcc dot gnu.org
2022-07-22 22:44 ` 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).