Debugging
bug - is a mistake or omission in program code that leads to errors when the program runs
debugging - refers to the process of locating and correcting a bug
interactive debugger - software tool designed to help located bugs
dynamic check - checks for undefined behavour
Undefined bugs
undefined behaviour - when certain uses of code shouldn't be done, like: arr[arr.size() + 1] here anything can happen (probs a crash or the program will continue with bad data)
segmentation fault (core dumped) - caused by accessing memory outside the allocated space for the program
Bugs can depend on:
- OS used
- compiler used, with options
- whats happened in the program so far
Assertions Lib
content in the page below
Using the compiler for undefined behaviour detection
Main
int main()
{
vector<int> v = {0,1,2,3,4};
v[5] = 5; // undefined behavour, out of range
}Flag
$ g++ -D_GLIBCXX_DEBUG main.cpp
// returns any undefined behavour