A
amit.codename13
Integer overflow...
The standard states integer overflow leads to undefined behavior...
I was trying to figure out why would any such overflow happen...
The standard way to modify a variable's value would be to use
assignment operators or unary operators like ++,--
consider, we are trying to store a large value in a integer type
variable
int i;
i=9999999999999999999999;
now the value on the right is converted to the type of left side as
per the following rule...
6.3.1.3
Otherwise, the new type is signed and the value cannot be represented
in it; either the
result is implementation-defined or an implementation-defined signal
is raised.
so why would it lead to undefined behavior?
The standard states integer overflow leads to undefined behavior...
I was trying to figure out why would any such overflow happen...
The standard way to modify a variable's value would be to use
assignment operators or unary operators like ++,--
consider, we are trying to store a large value in a integer type
variable
int i;
i=9999999999999999999999;
now the value on the right is converted to the type of left side as
per the following rule...
6.3.1.3
Otherwise, the new type is signed and the value cannot be represented
in it; either the
result is implementation-defined or an implementation-defined signal
is raised.
so why would it lead to undefined behavior?