public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "Casey at Carter dot net" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/66260] New: [C++14] Failure to compile variable template with recursively defined partial specialization
Date: Sat, 23 May 2015 05:20:00 -0000	[thread overview]
Message-ID: <bug-66260-4@http.gcc.gnu.org/bugzilla/> (raw)

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.


             reply	other threads:[~2015-05-23  5:20 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-23  5:20 Casey at Carter dot net [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-66260-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).