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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T12:59:00+00:00 2026-06-15T12:59:00+00:00

No idea what is going on here. I have a std stack of Vector3D’s

  • 0

No idea what is going on here. I have a std stack of Vector3D’s (a 3-dimensional vector class give to me by my tutor). I have pushed two Vector3D’s on to the stack but when I go to go the top one with vectorStack.top() I am treated to this very unhelpful error:

Debug Assertion Failed!

Expression: deque iterator not dereferenceble

I thought maybe there was something wrong with the Vector3D copy constructor but I’ve tried to make my own quick Vector3D struct (deleting the old one I was given) and that doesn’t work either!

Here is the code:

D3Dapp.cpp
if (!lsys.initialised)
{
    LSystem::ReproductionRule r1;
    r1.from = 'F';
    r1.to = "F+F-[FFF]";
    lsys.rules.push_back(r1);

    LSystem::ReproductionRule r2;
    r2.from = 'F';
    r2.to = "FF";
    lsys.rules.push_back(r2);

    lsys.result = lsys.generateResult("F", 0, 5);
    lsys.currentPosition = Vector3D(0.0f,0.0f,0.0f);
    lsys.vectorStack.push(lsys.currentPosition);

    lsys.initialised = true;
}

  lsys.result = "[FF]+FF";

if (!lsys.complete)
{
    for (int i=0; i < lsys.result.length();i++)
    {
  // F move forward
        if (lsys.result[i] == 'F')
        {
            float cosAng = cos(lsys.angle);
            float sinAng = sin(lsys.angle);

    Vector3D currentPosition(lsys.vectorStack.top());

            Vector3D newPosition = Vector3D(
                currentPosition.x + (cosAng * 0.5f), 
                currentPosition.y + (sinAng * 0.5f), 
                currentPosition.z);

            //lsys.vectorStack.push(newPosition);

            Vertex s, e;
            s.x = currentPosition.x;
            s.y = currentPosition.y;
            s.z = currentPosition.z;
            e.x = newPosition.x;
            e.y = newPosition.y;
            e.z = newPosition.z;

            startList.push_back(s);
            endList.push_back(e);

            lsys.currentPosition = newPosition;

    // + turn right
        } else if (lsys.result[i] == '+')
        {
            float rdn = 3.141592f / 180.0f;
            lsys.angle = (lsys.angle + 20.0f);

    // - turn left
        } else if (lsys.result[i] == '-')
        {
            float rdn = 3.141592f / 180.0f;
            lsys.angle = (lsys.angle - 20.0f);

    // [ push stack
        } else if (lsys.result[i] == '[')
  {
    lsys.vectorStack.push(lsys.currentPosition);

    // ] pop stack
  } else if (lsys.result[i] == ']')
  {
    lsys.vectorStack.pop();
  }
    }

    lsys.currentPosition = Vector3D(0.0f,0.0f,0.0f);
}

lsys.complete = true;

The stack in lsystem is just stack<Vector3D> vectorStack;

I’ve tried a variety of ways of assigning vectorStack.top() to current position but nothing seems to be working.

For completeness, here are the constructors to Vector3D:

Vector3D.h
Vector3D() {
    x = y = z = 0;
}

Vector3D(double a, double b, double c) {
    x = a;
    y = b;
    z = c;
}

Vector3D(const Vector3D& v) {
    x = v.x;
    y = v.y;
    z = v.z;
}

EDIT: To prove there is something in the stack
screenshot

This is the line in stack which throws the error
screenshot2

  • 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-15T12:59:01+00:00Added an answer on June 15, 2026 at 12:59 pm

    It turns out the framework I’m using (being forced to use) is built with very strict memory requirements in mind, there are several calls to ZeroMemory which seem to allocate this amount of memory and this amount of memory only.

    So when I start adding a load of dynamic memory structures like stacks and vectors everything goes to hell.

    ZeroMemory( this, sizeof(D3dApp) )
    

    After that removing the above I still had some issues but I followed Mark B’s advice and now its up and running.

    Many thanks.

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

Sidebar

Related Questions

I don't have the slightest idea what's going on here, and Google provides no
Hooooookay so here's another I just have no idea what's going on problem: The
I have no idea what's going on here and was hoping someone could help,
Have no idea whats going wrong here. Keeps throwing... Fatal error: Call to a
I have no idea what's going on here. I'm using R2006b. Any chance someone
Here is the two scripts I have Script 1: <? include('config.php'); $json = $_POST['payload'];
I have written some C++ code that generates a std::vector. I also have a
I'm having trouble getting MPI_Gatherv to work with a std::vector. I have written a
I'm going nuts trying to find the problem here. I have a main window,
I have a need to wrap a vector iterator, but don't like the idea

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.