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

I think the author of that blog was correct: the preferred path is for the compiler to provide data to the programmer to simplify the loop.

For your godbolt example, use the C compiler not c++



> I think the author of that blog was correct: the preferred path is for the compiler to provide data to the programmer to simplify the loop.

Requiring the equivalent of PGO is a rather unfortunate bar, though to be fair if you're that interested in performance it's probably something worth looking into anyways.

I'm curious how how noisy an always-on warning for undersized loop variables would be, or how much code would have broken if int were changed to 64 bits on 64-bit platforms...

> For your godbolt example, use the C compiler not c++

Sorry; that was a mistake on my end. The same phenomenon occurs when compiling in C mode, in any case [0].

[0]: https://godbolt.org/z/TvYrzncsc




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

Search: