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 invoke 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 terminate a.out
as soon as an error is detected? I.e. in such a way that it displays:
main.cpp:4:32: runtime error: division by zero
without displaying hello
on the following line? (because it will have terminated before)