开发者

Static code analysis tool for detecting uncaught exceptions in a C++ code before compilation?

开发者 https://www.devze.com 2022-12-28 00:59 出处:网络
I\'m looking for such a tool 开发者_如何学Cto be able to check fast if I catch all the exceptions I generate myself.

I'm looking for such a tool 开发者_如何学Cto be able to check fast if I catch all the exceptions I generate myself.

Thanks!


I think you're chasing the wind here, and the comments to Neil B's answer /should/ put you on the right track.

NEVER, EVER catch an exception just for the sake of it. Only catch exceptions where you can USEFULLY handle them. (example: retrying an operation on a backup server)

Remember almost every line of C++ can throw an AV (array index, pointer dereference, divide by zero, etc), so if you the approach of catching each of these, you'll get nowhere fast. You be heading for cargo cult coding world, where every pointer is checked for NULL before use.


Why not simply catch all possible exceptions:

int main() {
    try {
        // your stuff
    }
    catch( ... ) {
       // your handler
    }
}
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号