public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/102137] New: class template argument deduction with template template parameter allows explicit deduction guide
@ 2021-08-30 23:40 johelegp at gmail dot com
2021-08-31 13:57 ` [Bug c++/102137] " redi at gcc dot gnu.org
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: johelegp at gmail dot com @ 2021-08-30 23:40 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102137
Bug ID: 102137
Summary: class template argument deduction with template
template parameter allows explicit deduction guide
Product: gcc
Version: 12.0
Status: UNCONFIRMED
Keywords: accepts-invalid
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: johelegp at gmail dot com
CC: johelegp at gmail dot com
Target Milestone: ---
See https://godbolt.org/z/qc4e95TEK.
```C++
template<class T> struct B { B(int){} }; explicit B(int) -> B<int>;
template<template<class> class T> void f() { [[maybe_unused]] T _ = 0; }
void g() { f<B>(); }
```
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/102137] class template argument deduction with template template parameter allows explicit deduction guide
2021-08-30 23:40 [Bug c++/102137] New: class template argument deduction with template template parameter allows explicit deduction guide johelegp at gmail dot com
@ 2021-08-31 13:57 ` redi at gcc dot gnu.org
2021-08-31 15:02 ` ppalka at gcc dot gnu.org
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: redi at gcc dot gnu.org @ 2021-08-31 13:57 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102137
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
CC| |ppalka at gcc dot gnu.org
Last reconfirmed| |2021-08-31
Ever confirmed|0 |1
--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
This is so close to PR 101883 that I wonder if it shouldn't be closed as a dup
and the testcase added there. I'll confirm it and CC Patrick, so he can decide
if he thinks it's a dup or a separate issue.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/102137] class template argument deduction with template template parameter allows explicit deduction guide
2021-08-30 23:40 [Bug c++/102137] New: class template argument deduction with template template parameter allows explicit deduction guide johelegp at gmail dot com
2021-08-31 13:57 ` [Bug c++/102137] " redi at gcc dot gnu.org
@ 2021-08-31 15:02 ` ppalka at gcc dot gnu.org
2022-03-09 13:44 ` cvs-commit at gcc dot gnu.org
2022-03-09 13:53 ` ppalka at gcc dot gnu.org
3 siblings, 0 replies; 5+ messages in thread
From: ppalka at gcc dot gnu.org @ 2021-08-31 15:02 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102137
Patrick Palka <ppalka at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Assignee|unassigned at gcc dot gnu.org |ppalka at gcc dot gnu.org
Status|NEW |ASSIGNED
--- Comment #2 from Patrick Palka <ppalka at gcc dot gnu.org> ---
IMHO it might be good to track them separately since this one affects C++17
code but PR101883 affects only C++20 code (and the fix for the latter is
probably going to get backported).
Here's another accepts-invalid testcase, where the template template parm is
replaced by a dependent initializer:
template<class T> struct B { B(int){} }; explicit B(int) -> B<int>;
template<class T> void f(T t) { B _ = t; }
void g() { f(0); }
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/102137] class template argument deduction with template template parameter allows explicit deduction guide
2021-08-30 23:40 [Bug c++/102137] New: class template argument deduction with template template parameter allows explicit deduction guide johelegp at gmail dot com
2021-08-31 13:57 ` [Bug c++/102137] " redi at gcc dot gnu.org
2021-08-31 15:02 ` ppalka at gcc dot gnu.org
@ 2022-03-09 13:44 ` cvs-commit at gcc dot gnu.org
2022-03-09 13:53 ` ppalka at gcc dot gnu.org
3 siblings, 0 replies; 5+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-03-09 13:44 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102137
--- Comment #3 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:e32869a17b788bee9ca782b174a546b1db17b5ea
commit r12-7563-ge32869a17b788bee9ca782b174a546b1db17b5ea
Author: Patrick Palka <ppalka@redhat.com>
Date: Wed Mar 9 08:42:32 2022 -0500
c++: detecting copy-init context during CTAD [PR102137]
Here we're failing to communicate to cp_finish_decl from tsubst_expr
that we're in a copy-initialization context (via the LOOKUP_ONLYCONVERTING
flag), which causes us to always consider explicit deduction guides when
performing CTAD for a templated variable initializer.
It turns out this bug also affects consideration of explicit conversion
operators for the same reason. But consideration of explicit constructors
seems unaffacted thanks to code in build_aggr_init that sets
LOOKUP_ONLYCONVERTING when the initializer represents copy-initialization.
So this patch fixes this by making cp_finish_decl set LOOKUP_ONLYCONVERTING
just like build_aggr_init does, by inspecting the initializer, so that
callers don't need to explicitly pass this flag appropriately.
PR c++/102137
PR c++/87820
gcc/cp/ChangeLog:
* cp-tree.h (is_copy_initialization): Declare.
* decl.cc (cp_finish_decl): Set LOOKUP_ONLYCONVERTING
when is_copy_initialization is true.
* init.cc (build_aggr_init): Split out copy-initialization
check into ...
(is_copy_initialization): ... here.
* pt.cc (instantiate_decl): Pass 0 instead of
LOOKUP_ONLYCONVERTING as flags to cp_finish_decl.
gcc/testsuite/ChangeLog:
* g++.dg/cpp0x/explicit15.C: New test.
* g++.dg/cpp1z/class-deduction108.C: New test.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/102137] class template argument deduction with template template parameter allows explicit deduction guide
2021-08-30 23:40 [Bug c++/102137] New: class template argument deduction with template template parameter allows explicit deduction guide johelegp at gmail dot com
` (2 preceding siblings ...)
2022-03-09 13:44 ` cvs-commit at gcc dot gnu.org
@ 2022-03-09 13:53 ` ppalka at gcc dot gnu.org
3 siblings, 0 replies; 5+ messages in thread
From: ppalka at gcc dot gnu.org @ 2022-03-09 13:53 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102137
Patrick Palka <ppalka at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|--- |12.0
Resolution|--- |FIXED
Status|ASSIGNED |RESOLVED
--- Comment #4 from Patrick Palka <ppalka at gcc dot gnu.org> ---
Fixed for GCC 12.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2022-03-09 13:53 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-30 23:40 [Bug c++/102137] New: class template argument deduction with template template parameter allows explicit deduction guide johelegp at gmail dot com
2021-08-31 13:57 ` [Bug c++/102137] " redi at gcc dot gnu.org
2021-08-31 15:02 ` ppalka at gcc dot gnu.org
2022-03-09 13:44 ` cvs-commit at gcc dot gnu.org
2022-03-09 13:53 ` 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).