U
Urs Thuermann
I wasn't able to find an answer to the following questions in a draft
version of IOS 9899-99. What is the semantic when you decrement an
unsigned int below 0 (or subtract two unsigned ints with negative
result)? AFAIR, this results in implementation-defined behavior but
not undefined behavior. Is that correct?
So what does the standard say to this code?
void f(void)
{
unsigned int n = 0;
n--;
}
Also, do I have implementation-defined or undefined behavior, if I
decrement below zero but don't use the value, as in the following
code?
void f(unsigned int n)
{
while (n-- > 0) { /* In the last loop iteration, n is
; decremented from 0, but not used
} afterwards */
}
A short notice with section number in the standard would be nice
(as I think section numbering in my draft version is not that
different).
urs
version of IOS 9899-99. What is the semantic when you decrement an
unsigned int below 0 (or subtract two unsigned ints with negative
result)? AFAIR, this results in implementation-defined behavior but
not undefined behavior. Is that correct?
So what does the standard say to this code?
void f(void)
{
unsigned int n = 0;
n--;
}
Also, do I have implementation-defined or undefined behavior, if I
decrement below zero but don't use the value, as in the following
code?
void f(unsigned int n)
{
while (n-- > 0) { /* In the last loop iteration, n is
; decremented from 0, but not used
} afterwards */
}
A short notice with section number in the standard would be nice
(as I think section numbering in my draft version is not that
different).
urs