Let's say I have the following program:
#include <iostream>
float foo(float f)
{ return (f / 0); }
int main(void) {
foo(1.0f);
std::cout << "hello" << std::endl;
}
If I call clang++ -fsanitize=undefined main.cpp && ./a.out, then it will output:
main.cpp:4:32: runtime error: division by zero
hello
Is there a way to abort a.outas soon as an error is detected? That is, in such a way that it displays:
main.cpp:4:32: runtime error: division by zero
without displaying helloon the next line? (because it will be interrupted earlier)
source
share