Hacker News new | past | comments | ask | show | jobs | submit login

Psst…I'd mark that flag volatile or atomic if I were you; a smart C11 compiler might mark your loop as terminating ;)



It lives on the stack, it definitely isn't volatile.


Wait, why would it do that?


From a recent (http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1570.pdf) draft, section 6.8.5, Iteration statements:

> An iteration statement whose controlling expression is not a constant expression, that performs no input/output operations, does not access volatile objects, and performs no synchronization or atomic operations in its body, controlling expression, or (in the case of a for statement) its expression-3, may be assumed by the implementation to terminate.


For that condition to be met, the compiler would have to prove that g() doesn't do IO, etc - but the OP said it calls msgrcv(2), so it's not an issue.




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: