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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T08:34:33+00:00 2026-06-18T08:34:33+00:00

A program of mine throws a std::out_of_range . I know the reason for that,

  • 0

A program of mine throws a std::out_of_range. I know the reason for that, I’m accessing a vector with index -1 somewhere. What I don’t know is the name of the vector (variable name) and location in the code. The error message produced by my program looks like this:

terminate called after throwing an instance of 'std::out_of_range'
  what():  vector::_M_range_check
zsh: abort (core dumped)  ./main.x config.cfg  

whereas the error message produced by the code of some other guy (he uses g++ too) and posted in the question C++ accessing vector looks like this:

Error for vec.at(i).setVec(tmp);
Error is:  terminate called after throwing an instance of 'std::out_of_range'
  what():  vector::_M_range_check  

I.e. he is told the name of the variable. My question is:

Is there any way to tell g++/gcc to give me the extended info? Maybe even include line numbers (don’t know whether that’s possible but hey, a guy can dream 😉 ).
Just for funsies I ran my program in gdb with the catch thrown option (I might add, I have near zero experience in using an actual debugger) which didn’t tell me anything new either, in fact, it didn’t tell me that the error was due to a std::out_of_range exception.

Btw, my compiler flags (for debug) are:

CFLAGS = --exceptions -I$(ROOTSYS)/include --std=c++11 -Wall -g -O0 -fno-inline -fno-eliminate-unused-debug-types
  • 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-18T08:34:34+00:00Added an answer on June 18, 2026 at 8:34 am

    After hitting the breakpoint enter bt (backtrace) command in the gdb shell. This will print the stack trace (a sequence of function calls leading to the error).

    To get the variable name you can now use up command to navigate upwards in the stack and see what variables where used in each of those functions.

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

Sidebar

Related Questions

I would like to do conditional compilation in a program of mine. I know
For a program of mine I made a small function to clear the various
I've been trying to optimize a numeric program of mine, and have run into
A friend of mine was asked, during a job interview, to write a program
I am writing a program that read string and integers from file, then copy
I have written a program that is sort of an unofficial, standalone plugin for
In a school project of mine, I was requested to create a program without
I have some java code that looks similar to this: private void startServer() throws
I was writing a little program that takes a list and generates a menu
I was talking to a friend of mine that through my new code I

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.