David Bakin’s programming blog.


Visual C++: Letting C++ programmers get away with new murder without warning

Consider Visual C++.

This always correct code emits a completely useless warning:

try {
    ...
} catch (const std::exception& ex) {
    printf("foo\n");
}
test.cpp(3): warning C4101: 'ex' : unreferenced local variable

This never ever correct code doesn’t emit any warning at all:

throw new exception("foo");

Visual C++ is a totally awesome piece of technology.  So why doesn’t it work the way I want it to?