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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T23:02:18+00:00 2026-06-04T23:02:18+00:00

I try to access/print data from a vector3f which results in EXC_BAD_ACCESS : std::cout

  • 0

I try to access/print data from a vector3f which results in EXC_BAD_ACCESS:

std::cout << myMesh.faces[1].vertices[1].pos.x;

Code:

struct Vector2f{
    float x, y;
};
struct Vector3f{
    float x, y, z;
};

struct ObjMeshVertex{
    Vector3f pos;
    Vector2f texcoord;
    Vector3f normal;
};

struct ObjMeshFace{
    ObjMeshVertex vertices[3];
    ObjMeshFace(){}
    ObjMeshFace(const ObjMeshFace& o)
    {for (int i=0; i < 3; ++i) vertices[i] = o.vertices[i]; }
};

struct ObjMesh{
    std::vector<ObjMeshFace> faces;
};

ObjMesh myMesh;

for(size_t i = 0; i < faces.size(); ++i){
    ObjMeshFace face;
    for(size_t j = 0; j < 3; ++j){
        face.vertices[j].pos        = positions[(faces[i].pos_index[j] - 1)];
        face.vertices[j].texcoord   = texcoords[faces[i].tex_index[j] - 1];
        face.vertices[j].normal     = normals[faces[i].nor_index[j] - 1];
    }
    myMesh.faces.push_back(face);
}

The debugger refers to stl_vector.h:

  reference
  operator[](size_type __n)
  { return *(this->_M_impl._M_start + __n); }

What does this mean? Am i calling out of range?

  • 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-04T23:02:19+00:00Added an answer on June 4, 2026 at 11:02 pm

    It’s been a while, but when you do a push_back you are only shallow copying the vertices array vertices[] = vertices[]. You need a custom copy-ctor in ObjMeshFace. That’s why vertices[0].pos.x works and vertices[1].pos.x doesn’t.

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

Sidebar

Related Questions

I try to access the MainContentBlock control from the aspx, but unable to do
When I try to access the Host object from a non-static method declared in
When you try to access a key which isn't in a Dictionary (for example),
I want to access some data from Google maps. the only way possible is
When I try to access info that is not presented in xml like so:
My app crash when I try to access any property of my NSDecimalNumber amount_before_current_year:
I use cordova 1.6.1 and try to access the gps. But onSuccess function never
The error message I gen when I try to access the web page server
I am having an issue where I try to access the Lists.asmx web service
I have a scenario that when I try to access a hash key using

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.