I wonder how C++ behaves in this case:
char variable = 127;
variable++;
In this case, variable now equals to -128. However did the increment operator wrapped the value to its lower bound or did an overflow occurred?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
An overflow occured and results in undefined behavior.
Section 5.5:
The standard goes on to note that integer overflows are, in most implementations, ignored. But this doesn’t represent a guarantee.