logoalt Hacker News

anal_reactor • today at 7:35 AM • 2 replies • view on HN

Hard disagree. Obfuscated code is code that does something different from what it seems to be doing at first glance. This backwards loop does exactly the thing you'd expect it to do - in code review I'd only double-check whether it's actually correct - I can see someone making a mistake here and creating an infinite loop.

> I'm also honestly surprised that wraparound on unsigned types is not undefined behavior.

I consider it common knowledge TBH


Replies

kamiheku • today at 11:35 AM

> Obfuscated code is code that does something different from what it seems to be doing at first glance.

What you're describing is called "underhanded" code, see The Underhanded C Contest [0].

[0]: https://underhanded-c.org/_page_id_2.html

throw-qqqqq • today at 8:01 AM

> I consider it common knowledge TBH

For a seasoned C developer, I’d agree with you, but parent declares himself

> As someone who only writes C or C++ occasionally

… so I think it’s fair enough to not know such details.

C semantics has a few details that often surprise non-regulars, despite being such a small and simple language.

➕ show 1 reply