Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6939033
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T12:34:01+00:00 2026-05-27T12:34:01+00:00

While working on my own type erasure iterator, I ran into an issue where

  • 0

While working on my own type erasure iterator, I ran into an issue where the compiler (MSVC10) crashed with a stack overflow on this code:

struct base {};  //In actual code, this is a template struct that holds data
template<class category, class valuetype>  
    struct any;  //In actual code, this is abstract base struct
template<class basetype, class category, class valuetype> 
    struct from; //In actual code, this is function definitions of any

template<class valuetype>
struct any<void,valuetype>
{ void a() {} };
template<class category, class valuetype>  
struct any
    : public any<void,valuetype> //commenting this line makes it compile
{ void b() {} };        

template<class basetype, class valuetype>
struct from<basetype,void,valuetype>
    : public base  //commenting out _either_ of these makes it compile
    , public any<void,valuetype>
{ void c() {} };

int main() {
    from<int, void, char> a;
    a.a();
    a.c();
    any<int, char> b;
    b.a();
    b.b();
    return 0;
}

Obviously, I’ve removed everything I can where the bug remains. (Origional code was 780+ lines) Removing any remaining template parameters causes the code to compile.

The full error message is:

main.cpp(23): fatal error C1063: compiler limit : compiler stack overflow
    main.cpp(20) : see reference to class template instantiation 'from<basetype,void,valuetype>' being compiled

IDEOne compiles it fine. I’ve heard that MSVC implemented two-phase lookup wrong, which seems relevant, but doesn’t explain why it compiles when I remove the line that makes from inherit from base. Can anyone teach me why MSVC10 won’t compile this? What did I do that I should be avoiding?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T12:34:02+00:00Added an answer on May 27, 2026 at 12:34 pm

    As a workaround, consider introducing an additional class between the unspecialized any and the specialization with category = void:

    template <class valuetype>
    class detail_void_any
        : public any<void, valuetype>
    {
    };
    
    
    template<class category, class valuetype>
    class any
        : public detail_void_any<valuetype>
    {
    };
    

    The following complete program should compile without error:

    class base {};      // Data Holder (in reality it's templated, so required)
    template<class category, class valuetype>  
            class any;  // Virtual Function Interface
    template<class basetype, class category, class valuetype> 
            class from; // Virtual Function Implementation
    
    template<class valuetype>
    class any<void,valuetype>
    {};
    
    
    template <class valuetype>
    class detail_void_any
        : public any<void, valuetype>
    {
    };
    
    template<class category, class valuetype>
    class any
        : public detail_void_any<valuetype>
    {
    };
    
    template<class basetype, class valuetype>
    class from<basetype,void,valuetype>
            : public base  //commenting out _either_ of these makes it compile
            , public any<void,valuetype>
    {}; //this is line 23, where the compiler crashes
    
    int main() {return 0;}
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Background Lately I've become a fanatic that everything I type while working on a
While working in a Java app, I recently needed to assemble a comma-delimited list
While working between a Windows MySQL server and a Debian MySQL server, I noticed
While working on a project, I came across a JS-script created by a former
While working on a C++ project, I was looking for a third party library
While working on an existing project I suddenly got the following error when trying
While working a project tonight, I ended up using one .js resource file for
While working my way through the Android tutorials, I came across something I don't
While working with Java, I find it hard to position my main window in
While working with git-svn, and a 'typical' svn repo /trunk, /branches/..., /tags/... How do

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.