public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "pinskia at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/66153] Internal compiler error in nested template function
Date: Tue, 21 Dec 2021 21:29:55 +0000	[thread overview]
Message-ID: <bug-66153-4-YH5WQPtIyp@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-66153-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #8 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Reduced further:
#include <type_traits>

template <class T> struct TypeMapper { static const int NestLevel =
T::NestLevel; };
template<> struct TypeMapper<double> { static const int NestLevel = 0; };
template<class obj> struct Container { obj data; };
template<class obj> struct Recursive {
  enum { NestLevel = TypeMapper<obj>::NestLevel + 1};
};
template<int N,class obj,  typename std::enable_if<N==obj::NestLevel >::type *
= nullptr >
auto function(const obj &arg)-> obj
{
  return arg;
}
template<int N,class obj, typename std::enable_if<N!=obj::NestLevel >::type * =
nullptr >
  auto function(const obj &arg)-> obj
{
  return obj{};
}
template<int N,class obj>
  auto function(const Container<obj> & arg) ->
Container<decltype(function<N>(arg.data))>
{
  Container<Recursive<Recursive<double> > > ret;
  return ret;
}
int main(int argc,char **argv)
{
  Container<Recursive<Recursive<double> > > array;
  Container<Recursive<Recursive<double> > > ret;

  function<1>(array);
}

----- CUT -----
I have seen another one similar to this recently.

  parent reply	other threads:[~2021-12-21 21:29 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-15  0:21 [Bug c++/66153] New: " paboyle at ph dot ed.ac.uk
2015-05-15 11:42 ` [Bug c++/66153] " paboyle at ph dot ed.ac.uk
2015-05-16  4:41 ` paboyle at ph dot ed.ac.uk
2015-05-23 12:47 ` paboyle at ph dot ed.ac.uk
2021-12-21 21:11 ` pinskia at gcc dot gnu.org
2021-12-21 21:29 ` pinskia at gcc dot gnu.org [this message]
2021-12-21 21:45 ` pinskia at gcc dot gnu.org
2021-12-21 21:58 ` pinskia 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-66153-4-YH5WQPtIyp@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).