What happens when I assign a number larger than INT_MAX to an int?

It is implementation-defined behaviour. This means that your compiler must provide documentation saying what happens in this scenario.

So, consult that documentation to get your answer.

A common way that implementations define it is to truncate the input integer to the number of bits of int (after reinterpreting unsigned as signed if necessary).

C++14 Standard references: [expr.ass]/3, [conv.integral]/3

Leave a Comment