[PATCH] D34299: [ubsan] Improve diagnostics for return value checks (clang)

Alex Lorenz via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Jun 23 04:39:16 PDT 2017


arphaman added a comment.

Ok, so now the null check `return.sloc.load` won't call the checker in compiler-rt and so the program won't `abort` and won't hit the `unreachable`. I have one question tough:

This patch changes the behavior of this sanitizer for the example that I gave above. Previously a runtime diagnostic was emitted, but now there is none. While I'm not saying that the previous behaviour was correct, I'm wondering if the new behaviour is right.  I think that for C++ it makes sense, but I don't know the right answer for C. I'm leaning more towards the new behaviour, since technically in C falling off without returning a value is not UB unless that return value is used by the caller. But at the same time, since we don't diagnose `return` UB for C, maybe it's still worth diagnosing this particular issue? The user might not catch it otherwise at all (or they might catch it later when they try to access it, but by that point they might not know where the pointer came from). WDYT?


https://reviews.llvm.org/D34299





More information about the cfe-commits mailing list