why it is up to the compiler to decide what value to assign when assigning an out-of-range value to
- by Allopen
in C++ Primer 4th edition 2.1.1, it says "when assigning an out-of-range value to a signed type, it is up to the compiler to decide what value to assign".
I can't understand it. I mean, if you have code like "char 5 = 299", certainly the compiler will generate asm code like "mov BYTE PTR _sc$[ebp], 43"(VC) or "movb $43, -2(%ebp)"(gcc+mingw), it IS decided by the compiler.
but what if we assign a value that is given by the user input? like, via command line?
and the asm code generated will be "movb %al, -1(%ebp)"(gcc+mingw) and "
mov cl, BYTE PTR _i$[ebp]
mov BYTE PTR _sc$[ebp], cl
"(VC), so now how can compiler decide what will happen? I think now it is decided by the CPU.
Can you give me a clear explanation?