mcarrickscott commented on PR #95: URL: https://github.com/apache/incubator-milagro-crypto-c/pull/95#issuecomment-1449536033
Alas there is no such option -fno-strict-overflow And it is not wrap around that is wanted, we just need the bits to fall quietly off the end. A good compiler will do that - it will compile a left shift down to a single assembly language instruction. To subdue compiler errors like this you could perform entirely unnecessary masking just to get the compiler to stop complaining. But there may be a significant performance hit. For your example of 266483887285207040 you would need to set the high bits to zero, before the left shift. And hope that the compiler is smart enough to see that the masking is unnecessary and take it out again. So you end up (a) Inserting some code to get the compiler to shut up (b) Hope the compiler has the sense to remove the unnecessary code you just put in. ..or just learn to coexist with demons! Mike Mike Mike On Wed, Mar 1, 2023 at 11:49 AM Matthias Görgens ***@***.***> wrote: > @mcarrickscott <https://github.com/mcarrickscott> If you want controlled > overflow, ie wrap-around, you need the compiler option > -fno-strict-overflow. Otherwise you get undefined behaviour > <https://en.wikipedia.org/wiki/Undefined_behavior>. > > In the C community > <https://en.wikipedia.org/wiki/C_(programming_language)>, undefined > behavior may be humorously referred to as "nasal demons", after a > comp.std.c <https://en.wikipedia.org/wiki/Comp.*_hierarchy> post that > explained undefined behavior as allowing the compiler to do anything it > chooses, even "to make demons fly out of your nose". > > — > Reply to this email directly, view it on GitHub > <https://github.com/apache/incubator-milagro-crypto-c/pull/95#issuecomment-1449501345>, > or unsubscribe > <https://github.com/notifications/unsubscribe-auth/AAU3ZDUII2V5MYVQBWSLWITWZ35RTANCNFSM6AAAAAATEDLYUI> > . > You are receiving this because you were mentioned.Message ID: > ***@***.***> > -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
