On Mon, Mar 21, 2016 at 01:36:22AM +0100, Joerg Sonnenberger wrote: > In short, this is a real problem and the assumption is not specific to > clang. Revert now, please.
Is there any other hack around the issue? Marking the symbol weak is a very strange way to stop the compiler making this assumption. I have trouble seeing how the mis-optimization can be justified for external symbols anyway, but this may depend on the type they point to and the fine print. Your example with local/auto symbols certainly is very differnent to the link sets case. How about making the start/end symbols uintptr_t, then calculating the count upfront and casting start for the iteration? Martin