[PATCH] D29437: [ubsan] Detect signed overflow UB in remainder operations

Vedant Kumar via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Feb 2 00:25:12 PST 2017


vsk added a comment.

In https://reviews.llvm.org/D29437#664379, @regehr wrote:

> Does this check need to be sensitive to the dialect of C/C++ that the user asked for? I know that it used to be the case that the standard could be read either way for this case, but as you observe it is now unambiguously UB.


No, I don't think the check should be sensitive to language dialect.

You're right about the C99 spec not being very explicit about what 'a % b' means if 'a / b' is not representable. It's simply the "remainder" of 'a / b'. However, clang treats 'INT_MIN % -1' as having UB in C99 mode (rightly, imho), so it'd be nice to have a diagnostic for it.


https://reviews.llvm.org/D29437





More information about the cfe-commits mailing list