public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/102184] New: Explicit template instantiation is wrongly considered as specialization
@ 2021-09-03 6:52 fchelnokov at gmail dot com
2021-09-03 7:03 ` [Bug c++/102184] " pinskia at gcc dot gnu.org
2021-09-03 7:07 ` [Bug c++/102184] Explicit template instantiation thinks there is an ambiguous template specialization when there is none for concepts pinskia at gcc dot gnu.org
0 siblings, 2 replies; 3+ messages in thread
From: fchelnokov at gmail dot com @ 2021-09-03 6:52 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102184
Bug ID: 102184
Summary: Explicit template instantiation is wrongly considered
as specialization
Product: gcc
Version: 12.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: fchelnokov at gmail dot com
Target Milestone: ---
In this code:
```
template<int N> requires(N==1) int fib() { return 1; }
template<int N> requires(N==2) int fib() { return 1; }
template<int N> int fib() { return fib<N-1>() + fib<N-2>(); }
template int fib<1>();
```
the last line with function explicit instantiation produces GCC error:
ambiguous template specialization 'fib<1>' for 'int fib()'
The other compilers are fine with the code: https://gcc.godbolt.org/z/fbMGs3hqY
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug c++/102184] Explicit template instantiation is wrongly considered as specialization
2021-09-03 6:52 [Bug c++/102184] New: Explicit template instantiation is wrongly considered as specialization fchelnokov at gmail dot com
@ 2021-09-03 7:03 ` pinskia at gcc dot gnu.org
2021-09-03 7:07 ` [Bug c++/102184] Explicit template instantiation thinks there is an ambiguous template specialization when there is none for concepts pinskia at gcc dot gnu.org
1 sibling, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-09-03 7:03 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102184
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |diagnostic
--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
GCC is saying there is an ambigous specialization.
If I do this, GCC accepts the code:
template<int N> requires(N==1) int fib() { return 1; }
template<int N> requires(N==2) int fib() { return 1; }
template<int N> int fib() requires(N!=1 && N!=2) { return fib<N-1>() +
fib<N-2>(); }
template int fib<1>();
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug c++/102184] Explicit template instantiation thinks there is an ambiguous template specialization when there is none for concepts
2021-09-03 6:52 [Bug c++/102184] New: Explicit template instantiation is wrongly considered as specialization fchelnokov at gmail dot com
2021-09-03 7:03 ` [Bug c++/102184] " pinskia at gcc dot gnu.org
@ 2021-09-03 7:07 ` pinskia at gcc dot gnu.org
1 sibling, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-09-03 7:07 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102184
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Ever confirmed|0 |1
Status|UNCONFIRMED |NEW
Last reconfirmed| |2021-09-03
Keywords| |rejects-valid
Summary|Explicit template |Explicit template
|instantiation is wrongly |instantiation thinks there
|considered as |is an ambiguous template
|specialization |specialization when there
| |is none for concepts
--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Andrew Pinski from comment #1)
> GCC is saying there is an ambigous specialization.
>
> If I do this, GCC accepts the code:
> template<int N> requires(N==1) int fib() { return 1; }
> template<int N> requires(N==2) int fib() { return 1; }
> template<int N> int fib() requires(N!=1 && N!=2) { return fib<N-1>() +
> fib<N-2>(); }
> template int fib<1>();
But I think GCC does not know which specialization to instantiate here.
Because the following works just fine:
int t = fib<1>();
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-09-03 7:07 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-03 6:52 [Bug c++/102184] New: Explicit template instantiation is wrongly considered as specialization fchelnokov at gmail dot com
2021-09-03 7:03 ` [Bug c++/102184] " pinskia at gcc dot gnu.org
2021-09-03 7:07 ` [Bug c++/102184] Explicit template instantiation thinks there is an ambiguous template specialization when there is none for concepts pinskia 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).