Created
January 27, 2019 22:44
-
-
Save easyaspi314/392c6f63c738298c6f887a0252916d12 to your computer and use it in GitHub Desktop.
cppcheck bug
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ cppcheck --enable=style uint128mul.c | |
Checking uint128mul.c ... | |
[uint128mul.c:9]: (style) The scope of the variable 'botLo' can be reduced. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
typedef struct { | |
unsigned long long hi, lo; | |
} uint128_t; | |
typedef unsigned long long uint64_t; | |
uint128_t long_multiply(/* split uint128_t */ uint64_t topLo, uint64_t topHi) | |
{ | |
uint64_t botLo = 0x1234567890ABCDEFULL; | |
uint64_t retHi; | |
/* widening multiply */ | |
__asm__("mulq %[botLo]" : "+a" (topLo), "=d" (retHi) : [botLo] "r" (botLo)); | |
if (topHi != 0) { | |
topHi *= botLo; | |
} | |
return (uint128_t) { topLo, topHi }; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment