Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I don't see how that could not be a compiler error. The case b = 10 is more interesting because, as far as I can tell, it shows the differences between compilers that do two-phase lookup correctly and those that don't.

This seems to be a rare case where GCC is in the right, but I'd have to double-check the standard to be sure.



It was pointed out to me after I joined #llvm when considering reporting this that using the value of "b", which is defined after "a" in the class before it has been initialized is, I suppose obviously in retrospect, undefined behavior.

In effect, I was subverting the undefined behavior associated with expanding a set of infinitely deep template instantiations by accessing a variable that was as yet undefined at the point of access.

So, my initial retractions stand, and this compiler behavior will remain appropriately undefined.




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

Search: