[PATCH] D16310: new clang-tidy checker misc-long-cast

Daniel Marjamäki via cfe-commits cfe-commits at lists.llvm.org
Wed Feb 10 05:28:33 PST 2016


> You can get overflow with / and %. Consider:
>
> int i = INT_MIN / -1; // similar for %

you are right, I did not think of that. 

imho overflow still seems unlikely for / and %.

..................................................................................................................
Daniel Marjamäki Senior Engineer
Evidente ES East AB  Warfvinges väg 34  SE-112 51 Stockholm  Sweden

Mobile:                 +46 (0)709 12 42 62
E-mail:                 Daniel.Marjamaki at evidente.se

www.evidente.se

________________________________________
Från: Aaron Ballman [aaron.ballman at gmail.com]
Skickat: den 10 februari 2016 14:12
Till: Daniel Marjamäki
Kopia: reviews+D16310+public+4a30d2d4953885ca at reviews.llvm.org; alexfh at google.com; legalize at xmission.com; eugene.zelenko at gmail.com; cfe-commits at lists.llvm.org
Ämne: Re: [PATCH] D16310: new clang-tidy checker misc-long-cast

On Wed, Feb 10, 2016 at 3:23 AM, Daniel Marjamäki
<Daniel.Marjamaki at evidente.se> wrote:
>
> That is intentional.. you can't get overflow with / , % , & , | , etc...

You can get overflow with / and %. Consider:

int i = INT_MIN / -1; // similar for %

~Aaron

>
> ..................................................................................................................
> Daniel Marjamäki Senior Engineer
> Evidente ES East AB  Warfvinges väg 34  SE-112 51 Stockholm  Sweden
>
> Mobile:                 +46 (0)709 12 42 62
> E-mail:                 Daniel.Marjamaki at evidente.se
>
> www.evidente.se
>
> ________________________________________
> Från: Richard [legalize at xmission.com]
> Skickat: den 10 februari 2016 07:28
> Till: Daniel Marjamäki; aaron.ballman at gmail.com; alexfh at google.com
> Kopia: legalize at xmission.com; eugene.zelenko at gmail.com; cfe-commits at lists.llvm.org
> Ämne: Re: [PATCH] D16310: new clang-tidy checker misc-long-cast
>
> LegalizeAdulthood added inline comments.
>
> ================
> Comment at: clang-tools-extra/trunk/clang-tidy/misc/MisplacedWideningCastCheck.cpp:21-23
> @@ +20,5 @@
> +void MisplacedWideningCastCheck::registerMatchers(MatchFinder *Finder) {
> +  auto Calc = expr(anyOf(binaryOperator(anyOf(
> +                             hasOperatorName("+"), hasOperatorName("-"),
> +                             hasOperatorName("*"), hasOperatorName("<<"))),
> +                         unaryOperator(hasOperatorName("~"))),
> ----------------
> Sorry for the late observation, but why doesn't this check for `%` and `/` operators?
>
>
> Repository:
>   rL LLVM
>
> http://reviews.llvm.org/D16310
>
>
>


More information about the cfe-commits mailing list