S
subnet
What does the standard say about this:
#include <stdio.h>
void somefunc(int a, int b, int c)
{
printf("%d %d %d\n", a, b, c);
}
int main(void) {
int i = 5;
somefunc(i++, i++, i++);
return 0;
}
Compiling with gcc -Wall it gives:
prog.c: In function `main':
prog.c:10: warning: operation on `i' may be undefined
prog.c:10: warning: operation on `i' may be undefined
but it prints 7 6 5 anyway.
Are the function arguments guaranteed to be evaluated right-to-left or
this is not specified by the standard (and the above code produces
UB)?
Thanks
#include <stdio.h>
void somefunc(int a, int b, int c)
{
printf("%d %d %d\n", a, b, c);
}
int main(void) {
int i = 5;
somefunc(i++, i++, i++);
return 0;
}
Compiling with gcc -Wall it gives:
prog.c: In function `main':
prog.c:10: warning: operation on `i' may be undefined
prog.c:10: warning: operation on `i' may be undefined
but it prints 7 6 5 anyway.
Are the function arguments guaranteed to be evaluated right-to-left or
this is not specified by the standard (and the above code produces
UB)?
Thanks