mcarrickscott commented on PR #95:
URL: 
https://github.com/apache/incubator-milagro-crypto-c/pull/95#issuecomment-1449622481

   In C
   
   a[NLEN_XXX - 1] = ((a[NLEN_XXX - 1] << n)) | (a[NLEN_XXX - 2] >>
   (BASEBITS_XXX - n));
   
   causes an apparent problem. Undefined behaviour. In Rust (release mode)
   
   self.w[NLEN - 1] = (self.w[NLEN - 1] << n) | (self.w[NLEN - 2] >> (BASEBITS
   - n));
   
   works just fine without complaint. And Rust has the reputation of being the
   safer language!
   
   So the solution seems to be
   
   (a) By all means test the code in debug mode with sanitizers on, to
   highlight things that could be a problem.
   (b) When you are sure that your code is not actually generating a real bug,
   remove the guard rails/training wheels and let rip!
   
   If it is good enough for Rust, it is good enough for me.
   
   
   Mike
   
   
   
   
   On Wed, Mar 1, 2023 at 12:41 PM Michael Scott ***@***.***> wrote:
   
   > So don't ever do negative shifts!
   >
   > On Wed, Mar 1, 2023 at 12:36 PM Matthias Görgens ***@***.***>
   > wrote:
   >
   >> Here's the shift-example
   >> 
<https://godbolt.org/#z:OYLghAFBqd5TKALEB7ArgFwA5YDQCWIEAxqgLbYEA2ApgE4ByAhubSAOQAeAHAGwBaPgBYA1MBIlRATgB0wjnloATAplT0CykAEY8AM1QA7TAGUSzOruEHjmAKoBnWgAUunAAyKAVrrwB3emZsTh0OAEo8ak4AVkUjT0VUTgB5LFxMUVR9UV5BEXFJGXlRCABhCio6elEAUgAmAGYdcMVMRPDIpFpmZQZiSIBrEBiPKM4FPHIRsYSOLzxkjkVHEDH2%2BYi8OFgUDBx8IlJKmgYWNk48oTEJKTlJlTUNLT9DE3NLdh0bN4dnN0SeF89QCQRCHDCkWiHDieDmCyWaQOmWyuX410KdxK5RO1TqTXqrTwGy8nTw3V6/QgUImimmozhgKWKzWxI6Qxm4w4jXiTM4bQ620QEBQZD6AFFVOp6IRiPpTkZWOwIYpfh8rN9bCYnK53JsgX5qMwjKAAPrmkh4Zx0EiYAjGYi0IzKCrUdDkBJ6J3KAAyBCMtEY7oARv1pHhsKhHGp7UZXe7PRGozHjH6A0HyKH6CBw9baLbY6ZMMx6Jh4x6/HmC8YiyXMGnAyGw1bi6Xy4nHK36/7G5mw5FHBh6CRlQ1Gv6SG6%2BrVGmVO6pULIkDPxbUPABBMcTqe0GdzzCqExLldr9f%2BzLkZj%2B6l1ADsACFT6JROeRKbMsGZ4%2BN8/g3VGgAIqIjRfk%2BojYJoJj6BADT1A0MTKP%2Bq6NOKogCDo/5AfB1DKLUMRlEYsF4KIwbEX%2BJ4oWhLSgT%2Boj0LQmDoPQRiiB4NGbreAGnls0KwvCSScGUoiDkxI74s0AqbJEIogGQlCnDKRxyVU/QkMA0g2H0ABuBAjgAagQtD%2BCk2BOqEqo0JgDCrBAwaAsG/olgAnuZeByWwJgpEY1AufqfSXiaVh%2BQQ9EFlptCrPqtBcPmWDKgs560NCCzUAQwZB
 
PQTkVH0gKYJo0wqpE%2BhGsAjgGUZJlmSqWpmBYGo/HYOoAvqvh6EaJogOapqWqlwarJAkSoNgdrGJFKxJfmI0JBA3rtn43oNhmWZ%2BJG0ZTXNeirSmRiLU22Z6FWU21m2qBuhWB0TdWRjHd26Z7ZWXYbS2da7X2%2B0DkOI66DSMK8vqSxovkNxFPcpSSk8NRji0kmktsoq4gwsrHPJ1Syepmm0Dp%2BmGcZplzGEBiWdZxB2fqDmKplrnuU6mBeT5gL%2BcawBBQsqihXa4WRQs0WxVZgKJclii9RlWWoDl%2Bp5QQBWQgYJVlTjlX46qdjql8DXav8eoLMCURM51FpRGl/XUosw2xpFAgpDyVqXVNjrOk9C09kt/Sbcm62nQmK3u7Gr3LRdNpHY9nvnTbgeFl2fuu89J1nR2kfO/dLRWp9Xw/XxfIcIDGK3MUYgQOD0ridDbJSRyDLQpM0w6B4syZyyegkhEP31H9CL8qXpKROF9DRg6whAA%3D%3D>
   >> I mentioned.
   >>
   >> #include<stdio.h>
   >> #include<stdint.h>int main() {
   >>   int64_t b;
   >>   b = 3;
   >>   printf("%d >> -1 = %ld\n", b, b >> -1);
   >>   return 0;
   >> }
   >>
   >> Depending on compiler options, it can output 3 >> -1 = 0 or 3 >> -1 = 6
   >> (amongst other possible behaviours).
   >>
   >> —
   >> Reply to this email directly, view it on GitHub
   >> 
<https://github.com/apache/incubator-milagro-crypto-c/pull/95#issuecomment-1449565992>,
   >> or unsubscribe
   >> 
<https://github.com/notifications/unsubscribe-auth/AAU3ZDVGCT7EXZQYVCGXWNTWZ4C7LANCNFSM6AAAAAATEDLYUI>
   >> .
   >> 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]

Reply via email to