public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/96124] New: Template specialization auto
@ 2020-07-08 19:57 amal029 at outlook dot com
2020-12-10 17:20 ` [Bug c++/96124] " redi at gcc dot gnu.org
0 siblings, 1 reply; 2+ messages in thread
From: amal029 at outlook dot com @ 2020-07-08 19:57 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96124
Bug ID: 96124
Summary: Template specialization auto
Product: gcc
Version: 10.1.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: amal029 at outlook dot com
Target Milestone: ---
#include <iostream>
template <auto N, auto M>
struct Add {
const static auto res = Add<N + 1, M - 1>::res;
};
template <auto N>
struct Add<N, 0> { const static auto res = N; };
/* This does not work, the second template argument overflows in Add struct */
/* Clang handles both cases correctly. */
template <std::size_t N>
//template <auto N> /* This works uncomment this line and comment the above
line to make it work */
auto Forall() { return Forall<N - 1>() + Add<N, N - 1>::res; }
template <>
auto Forall<0>() { return 0; }
int main(void) {
std::cout << Forall<3>() << "\n";
return 0;
}
See the comments in the code. I ran it on compiler explorer with both g++ 10.1
and gcc-trunk (x86-64); both fail. I should be able to narrow types myself.
Options when compiling -std=c++2a
^ permalink raw reply [flat|nested] 2+ messages in thread
* [Bug c++/96124] Template specialization auto
2020-07-08 19:57 [Bug c++/96124] New: Template specialization auto amal029 at outlook dot com
@ 2020-12-10 17:20 ` redi at gcc dot gnu.org
0 siblings, 0 replies; 2+ messages in thread
From: redi at gcc dot gnu.org @ 2020-12-10 17:20 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96124
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Ever confirmed|0 |1
Last reconfirmed| |2020-12-10
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-12-10 17:20 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-08 19:57 [Bug c++/96124] New: Template specialization auto amal029 at outlook dot com
2020-12-10 17:20 ` [Bug c++/96124] " redi 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).