public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/66260] New: [C++14] Failure to compile variable template with recursively defined partial specialization
@ 2015-05-23  5:20 Casey at Carter dot net
  2015-08-05 15:40 ` [Bug c++/66260] " jason at gcc dot gnu.org
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: Casey at Carter dot net @ 2015-05-23  5:20 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66260

            Bug ID: 66260
           Summary: [C++14] Failure to compile variable template with
                    recursively defined partial specialization
           Product: gcc
           Version: 6.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: Casey at Carter dot net
  Target Milestone: ---

Created attachment 35604
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=35604&action=edit
testcase.cpp

Both GCC 5.1.0 and 6.0 fail to compile this program:

template <class>
constexpr bool foo = false;
template <>
constexpr bool foo<int> = true;
template <class T, int N>
constexpr bool foo<T[N]> = foo<T>;

static_assert(foo<int>, "");
static_assert(!foo<double>, "");
static_assert(foo<int[3]>, "");
static_assert(!foo<double[3]>, "");
static_assert(foo<int[2][5][3]>, "");
static_assert(!foo<double[2][5][3]>, "");

int main() {}

5.1.0 doesn't seem to recognize that foo is a template-name in the definition
of the foo<T[N]> partial specialization:

prog.cc:6:33: error: expected primary-expression before '>' token
 constexpr bool foo<T[N]> = foo<T>;
                                 ^
prog.cc:6:34: error: expected primary-expression before ';' token
 constexpr bool foo<T[N]> = foo<T>;
                                  ^
prog.cc:6: confused by earlier errors, bailing out

6.0 20150522 at least tries to compile the recursion, but fails nonetheless:

prog.cc: In instantiation of 'constexpr const bool foo':
prog.cc:6:16:   recursively required from 'constexpr const bool foo'
prog.cc:6:16:   required from 'constexpr const bool foo'
prog.cc:10:15:   required from here
prog.cc:6:16: fatal error: template instantiation depth exceeds maximum of 900
(use -ftemplate-depth= to increase the maximum)
 constexpr bool foo<T[N]> = foo<T>;
                ^
compilation terminated.


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2015-08-06 18:45 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-05-23  5:20 [Bug c++/66260] New: [C++14] Failure to compile variable template with recursively defined partial specialization Casey at Carter dot net
2015-08-05 15:40 ` [Bug c++/66260] " jason at gcc dot gnu.org
2015-08-05 17:34 ` jason at gcc dot gnu.org
2015-08-05 17:56 ` jason at gcc dot gnu.org
2015-08-06  4:10 ` jason at gcc dot gnu.org
2015-08-06  4:16 ` jason at gcc dot gnu.org
2015-08-06 14:26 ` jason at gcc dot gnu.org
2015-08-06 14:29 ` jason at gcc dot gnu.org
2015-08-06 18:45 ` jason 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).