| I have an issue with this one:
Assume x has type int . Is the expression x<<32 ... Defined for all values of x Defines for some values of x Defined for no values of x (chose second answer)
Wrong answer Shifting (in either direction) by an amount equalling or exceeding the bitwidth of the promoted operand is an error in C99. So according to Wikipedia: https://en.wikipedia.org/wiki/C_data_types int
signed
signed int Basic signed integer type. Capable of containing at least the [−32,767, +32,767] range.[3][a] So a minimum of 16 bits is used for int, but no maximum is specified. Thus, if my C compiler on my 64-bit architecture uses 64 bits for int, this is perfectly allowed by the specification and my answer is correct. |
> All other things being equal, assume GCC/LLVM x86/x64 implementation-defined behaviors.
However, you're right to point out that the quiz would be better if you can't make any more assumptions than guaranteed by the basic language standard.