So, I am just minding my own buisness and trying to get some code to work when suddenly the debugger tells me that "Program Received signal SIGSEGV".
Apparently that error occurs when the code tries to access a memory location that it can't or shouldn't access.
Interesting ...
So, I started "single-stepping" through the programm and narrowed the error down to the following funtion.
It gets called two times, the first time it is called (with a parameter of 0), everything is fine, but the second time it gets called (with a paramter of 0), the error occurs.
There is a 2D vector (EventTable) to which this function adds a new column in a specified row.
1 2 3 4 5 6 7 8 9 10 11 12 13 14
|
bool CreateNewEventEntry(int RowToAddTo )
{
//Function to add a cell at the end of the specifed row to the table
UI.DisplayMessageBox("FUNCTION","CreateNewEventEntry");
EventTable[RowToAddTo].push_back( {} ) ;
// add a column (push back a default constructed cell)
SimulationInformation.NumberOfEventsInString[RowToAddTo] = SimulationInformation.NumberOfEventsInString[RowToAddTo] + 1;
//Set the member variables of the created entry to the default values, the following line is just an example
EventTable[RowToAddTo]SimulationInformation.NumberOfEventsInString[RowToAddTo]].ExampleVariable = 0;
return true;
}
| |
So, I had a thought.
Should I create a function for reading from / writing into a vector/array that handles "out of bounds-checking" and all of that?
Beause if I added those things everytime the vector / array gets accessed would result in some even harder to read code ...
Any thoughts on this?