public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/108347] New: Incorrect error: ambiguous template instantiation
@ 2023-01-09 22:37 CoachHagins at gmail dot com
2023-01-09 22:56 ` [Bug c++/108347] " pinskia at gcc dot gnu.org
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: CoachHagins at gmail dot com @ 2023-01-09 22:37 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108347
Bug ID: 108347
Summary: Incorrect error: ambiguous template instantiation
Product: gcc
Version: 13.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: CoachHagins at gmail dot com
Target Milestone: ---
Created attachment 54222
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=54222&action=edit
C++ source - no include directives
The attached code is a single .cpp file, as it contains no #include directives.
I have also posted on compiler explorer here: https://godbolt.org/z/jjEPKdx8Y
The code compiles fine with all versions of clang from 7 up through the latest
branch on CE.
The code FAILS to compile with gcc, all versions from 7 up through the latest
branch on CE.
There are THREE #defines in the included code, which provide three different
"fixes" to make the code compile.
The command
g++ -std=c++17 -DFIX0=0 -DFIX1=0 -DFIX2=0
will fail to compile with an ambiguous template instantiation error. However,
all of the following will allow the code to compile. Hopefully, the various
"fixes" will help identify the underlying issue(s).
g++ -std=c++17 -DFIX0=0 -DFIX1=0 -DFIX2=1
g++ -std=c++17 -DFIX0=0 -DFIX1=1 -DFIX2=0
g++ -std=c++17 -DFIX0=0 -DFIX1=1 -DFIX2=1
g++ -std=c++17 -DFIX0=1 -DFIX1=0 -DFIX2=0
g++ -std=c++17 -DFIX0=1 -DFIX1=0 -DFIX2=1
g++ -std=c++17 -DFIX0=1 -DFIX1=1 -DFIX2=0
g++ -std=c++17 -DFIX0=1 -DFIX1=1 -DFIX2=1
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/108347] Incorrect error: ambiguous template instantiation
2023-01-09 22:37 [Bug c++/108347] New: Incorrect error: ambiguous template instantiation CoachHagins at gmail dot com
@ 2023-01-09 22:56 ` pinskia at gcc dot gnu.org
2023-01-09 22:56 ` pinskia at gcc dot gnu.org
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-01-09 22:56 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108347
--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Well MSVC has an internal compiler error with this code.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/108347] Incorrect error: ambiguous template instantiation
2023-01-09 22:37 [Bug c++/108347] New: Incorrect error: ambiguous template instantiation CoachHagins at gmail dot com
2023-01-09 22:56 ` [Bug c++/108347] " pinskia at gcc dot gnu.org
@ 2023-01-09 22:56 ` pinskia at gcc dot gnu.org
2023-01-09 23:10 ` pinskia at gcc dot gnu.org
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-01-09 22:56 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108347
--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Created attachment 54223
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=54223&action=edit
testcase that removes the C++17isms and convert it over to C++11
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/108347] Incorrect error: ambiguous template instantiation
2023-01-09 22:37 [Bug c++/108347] New: Incorrect error: ambiguous template instantiation CoachHagins at gmail dot com
2023-01-09 22:56 ` [Bug c++/108347] " pinskia at gcc dot gnu.org
2023-01-09 22:56 ` pinskia at gcc dot gnu.org
@ 2023-01-09 23:10 ` pinskia at gcc dot gnu.org
2023-09-18 18:41 ` cvs-commit at gcc dot gnu.org
2023-09-18 18:42 ` ppalka at gcc dot gnu.org
4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-01-09 23:10 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108347
--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Andrew Pinski from comment #2)
> Created attachment 54223 [details]
> testcase that removes the C++17isms and convert it over to C++11
The reason why I did this is because I wanted to see if older versions of GCC
rejected this code and they do in a similar fashion. (MSVC still ICEs).
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/108347] Incorrect error: ambiguous template instantiation
2023-01-09 22:37 [Bug c++/108347] New: Incorrect error: ambiguous template instantiation CoachHagins at gmail dot com
` (2 preceding siblings ...)
2023-01-09 23:10 ` pinskia at gcc dot gnu.org
@ 2023-09-18 18:41 ` cvs-commit at gcc dot gnu.org
2023-09-18 18:42 ` ppalka at gcc dot gnu.org
4 siblings, 0 replies; 6+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-09-18 18:41 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108347
--- Comment #4 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:a6ac1fc64c3caed19da65c2e6b12f8ddaf551231
commit r14-4110-ga6ac1fc64c3caed19da65c2e6b12f8ddaf551231
Author: Patrick Palka <ppalka@redhat.com>
Date: Mon Sep 18 14:41:07 2023 -0400
c++: unifying identical tmpls from current inst [PR108347]
Here more_specialized_partial_spec wrongly considers the two partial
specializations to be unordered ultimately because unify for identical
parm=arg=A<T>::C returns failure due to C being dependent.
This patch fixes this by relaxing unify's early-exit identity test to
also accept dependent decls; we can't deduce anything further from them
anyway. In passing this patch removes the CONST_DECL case of unify:
we should never see the CONST_DECL version of a template parameter here,
and for other CONST_DECLs (such as enumerators) it seems we can rely on
them to already have been folded to their DECL_INITIAL.
PR c++/108347
gcc/cp/ChangeLog:
* pt.cc (unify): Return unify_success for identical dependent
DECL_P 'arg' and 'parm'.
<case CONST_DECL>: Remove handling.
gcc/testsuite/ChangeLog:
* g++.dg/template/ttp41.C: New test.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/108347] Incorrect error: ambiguous template instantiation
2023-01-09 22:37 [Bug c++/108347] New: Incorrect error: ambiguous template instantiation CoachHagins at gmail dot com
` (3 preceding siblings ...)
2023-09-18 18:41 ` cvs-commit at gcc dot gnu.org
@ 2023-09-18 18:42 ` ppalka at gcc dot gnu.org
4 siblings, 0 replies; 6+ messages in thread
From: ppalka at gcc dot gnu.org @ 2023-09-18 18:42 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108347
Patrick Palka <ppalka at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Target Milestone|--- |14.0
Assignee|unassigned at gcc dot gnu.org |ppalka at gcc dot gnu.org
Resolution|--- |FIXED
CC| |ppalka at gcc dot gnu.org
--- Comment #5 from Patrick Palka <ppalka at gcc dot gnu.org> ---
Fixed for GCC 14, thanks for the bug report.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2023-09-18 18:42 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-09 22:37 [Bug c++/108347] New: Incorrect error: ambiguous template instantiation CoachHagins at gmail dot com
2023-01-09 22:56 ` [Bug c++/108347] " pinskia at gcc dot gnu.org
2023-01-09 22:56 ` pinskia at gcc dot gnu.org
2023-01-09 23:10 ` pinskia at gcc dot gnu.org
2023-09-18 18:41 ` cvs-commit at gcc dot gnu.org
2023-09-18 18:42 ` 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).