why it is up to the compiler to decide what value to assign when assigning an out-of-range value to
Posted
by Allopen
on Stack Overflow
See other posts from Stack Overflow
or by Allopen
Published on 2010-06-05T14:55:52Z
Indexed on
2010/06/05
15:02 UTC
Read the original article
Hit count: 184
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?
© Stack Overflow or respective owner