Real world experience
Real world experience
Posted May 22, 2011 18:43 UTC (Sun) by cbcbcb (subscriber, #10350)In reply to: Real world experience by tialaramex
Parent article: What Every C Programmer Should Know About Undefined Behavior #3/3
If an operation in /* initialise */ performs a store which could alias with length then (as far as the analysis is concerned) the 2nd loop may run more iterations than the first.for (int k = 0; k < length; ++k) { /* initialise */ } for (int k = 0; k < length; ++k) { /* do something */ } for (int k = 0; k < length; ++k) { /* wrap up */ } Clang's analysis appears to claim that if the first loop exists immediately, but the second loop gets run, we access uninitialised bytes. Well, OK. But, how can one of these identical loops with constant length run, and not the others?