Compiler Team,
My C2000 customer (cgtools v6.4.2) has written some code that has "Undefined" behavior per the ANSI-C99 spec. Here is an example
int x[10], y[10], i;
void foo() {
for(i=0; i<10; ) {
y[i] = x[i++]*x[i++];
}
}
The ANSI-C spec violation is section 6.5 of the C99 spec:
“Between the previous and next sequence point an object shall have its stored value modified at most once by the evaluation of an expression.”
Very well. The customer however wants to know if the compiler can flag a diagnostic for such occurrences. I played around with various compiler options, such as K&R parsing, strict ANSI parsing, Issue Remarks, and so on. I cannot get the compiler to issue a diagnostic.
Is it possible to get a diagnostic for the above? (I suspect not)
Customer is pretty vocal that the compiler should be flagging undefined C-statements. Maybe it should, or maybe not. Seems reasonable here that the compiler should at least issue a very low level diagnostic (e.g., a remark at least). Can you comment?
Thank you and regards,
David