Integer overflow...

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?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Overflow errors? 3
Catching integer overflow 40
check integer overflow with GCC 4.5.2 19
Overflow on INTEGER value. 24
Implicit integer promotion 18
overflow 7
signed integer overflow 27
C99 integer types 24

Members online

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,528
Members
45,000
Latest member
MurrayKeync

Latest Threads

Top