Hallo,
On 19/01/16 14:39, Marc Feeley wrote:
Strange that this is undefined behavior in C. Is it only when left shifting a constant or any signed integer expression? In general I can understand it is undefined because it depends on the size of the integer type, but here ___TB is 3 so -7<<___TB will fit in any integer type including 8 bit integers!
The standard call those "expressions", so it shouldn't be limited to constants only. But those get caught during compile time. Interestingly, for right shifts the result is implementation-defined instead of undefined.
Also, I don’t understand why gsi gets stuck. After all you only got warnings.
Given the undefined behaviour the compiler can do whatever it wants, including optimizing those expressions away, but I am just guessing.
Can you give more details, such as OS and Gambit versions? I use the latest clang from Xcode and don’t have this problem.
This is Ubuntu 14.04 with Clang 3.7.1. I downloaded the LLVM binary distribution from http://www.llvm.org/. Gambit version 4.8.3.
Cheers,