We have a die function that outputs an error message and exits, e.g.:
void die(const char* msg) {
fprintf(stderr, "Error: %s\n", msg);
exit(1);
}
We use Parasoft C++test to statically analyze our code, but it doesn't realize that die is a non-returning function. So when it sees code like:
void foo(Bar* bar) {
if(!bar) {
die("bar is NULL");
}
Bar bar2 = *bar;
}
It warns that *bar might be dereferencing a null pointer, even though bar being NULL would prevent that line from ever executing. Is there a way to mark die as non-returning in a way Parasoft would recognize?
Edit: I need something that works in both GCC and VS 2003, but I'm not above #ifdefing my way around things if somebody has a solution that only works in VS