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 8234183
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T18:23:30+00:00 2026-06-07T18:23:30+00:00

I have a problem with compiling llvm. The problem is that my current compiler

  • 0

I have a problem with compiling llvm. The problem is that my current compiler (clang + libc++) tries to instantiate a template before the template parameter gets defined. Here is the code example:

// ----- TYPEDEFS -----
class NodeEntry;
class EdgeEntry;

typedef std::list<NodeEntry> NodeList;
typedef std::list<EdgeEntry> EdgeList;

typedef NodeList::iterator NodeItr; // line 39 
typedef NodeList::const_iterator ConstNodeItr;

typedef EdgeList::iterator EdgeItr;
typedef EdgeList::const_iterator ConstEdgeItr;

typedef std::list<EdgeItr> AdjEdgeList;

typedef AdjEdgeList::iterator AdjEdgeItr;

class NodeEntry {
private:  
  AdjEdgeList adjEdges;
  ...
};

class EdgeEntry {
private:
  AdjEdgeItr node1AEItr, node2AEItr;
  ...
};

The error from the compiler is this:

error: field has incomplete type 'PBQP::Graph::NodeEntry'

/Developer/Extras/llvm/include/llvm/CodeGen/PBQP/Graph.h:39:13: note: in instantiation of template class
  'std::__1::list<PBQP::Graph::NodeEntry, std::__1::allocator<PBQP::Graph::NodeEntry> >' requested here
typedef NodeList::iterator NodeItr;
        ^
/Developer/Extras/llvm/include/llvm/CodeGen/PBQP/Graph.h:31:11: note: forward declaration of 'PBQP::Graph::NodeEntry'
class NodeEntry;

As far as I can tell the compiler tries to instantiate std::list<NodeEntry> in order to get the iterator. This fails as NodeEntry is not defined yet. And of course EdgeEntry is using NodeEntry and vice versa.

The obvious question is: How do I fix it?
The educational question is: Why does the compiler try to instantiate the template when defining the type? Should it not wait until we do something with the list?

Thanks.

  • 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-06-07T18:23:32+00:00Added an answer on June 7, 2026 at 6:23 pm

    If you want guaranteed support for incomplete types, your best bet is to create unique_ptr‘s to them:

    typedef std::list<std::unique_ptr<NodeEntry>> NodeList;
    typedef std::list<std::unique_ptr<EdgeEntry>> EdgeList;
    

    In the past, many times std::list<incomplete_type> would just work. However with C++11 and noexcept specifications, it is becoming more likely that a complete type is needed, just so that the noexcept spec can be validated.

    C++11 guarantees that unique_ptr<incomplete_type> and shared_ptr<incomplete_type> will work, although there are strict limits. For example wherever ~unique_ptr() is executed, the type has to be complete there. But you can usually outline such code to a source and #include the complete type at that point.

    unique_ptr<incomplete_type> and shared_ptr<incomplete_type> are the only class templates in the C++11 std::lib that are guaranteed to work with incomplete types. Everything else is undefined behavior:

    [res.on.functions]/p2/b5:

    In particular, the effects are undefined in the following cases:

    …

    • if an incomplete type (3.9) is used as a template argument when instantiating a template component, unless specifically allowed for that component.

    If for some reason the std::list does not need to own the pointer to the incomplete type, then std::list<NodeEntry*> would work even better. You might also want to entertain using vector instead of list since the cost of moving pointers (or even unique_ptr‘s) around is relatively small.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a problem compiling Haskell programs, that import the Text.Regex.Posix module. I have
I have a problem when compiling JNI. It returns the error message like that
I have a problem with compiling C application, the errors that are shown are
I have a problem with compiling an Oracle trigger via SQL*PLUS - I don't
The problem is this: I have multiple competing threads (100+) that need to access
I have a problem compiling with ocamlopt and floats I'm under Ubuntu 10.04 and
I have a problem compiling a program I made in BASIC. It's a DOS
I have a problem in compiling a qt example from c++ GUI programming with
I have a problem when compiling a generic class with an inner class. The
Hello I have a problem with compiling a ghostscript from ports in openbsd 4.7.

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.