Can I confirm that the following C code gives undefined result for b:
unsigned a = 0;
int b = a - 1;
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.
(§6.3.1.3/3): “…either the result is implementation-defined or an implementation-defined signal is raised.”
On typical twos-complement hardware, I’d expect the result to be -1.
Note that the result is implementation defined, not undefined.