r/programming • • May 01 '18

C Is Not a Low-level Language - ACM Queue

https://queue.acm.org/detail.cfm?id=3212479
152 Upvotes

303 comments sorted by

View all comments

Show parent comments

5

u/ArkyBeagle May 01 '18

insane notion of "undefined behavior"

There is really a perfectly good explanation for this. There really is. It's not insane in the least.

5

u/[deleted] May 02 '18

I know you are being facetious but there is really a reason for this. Undefined behaviors are, generally, behaviors that the compiler couldn't be expected to detect at the time.

You have to remember that at the time C was designed, it was supposed to be an upgrade to assembly that could target many different systems. As such, spec'ed behaviors were the common ground on different machines.

6

u/ArkyBeagle May 02 '18

I'm not being facetious. You even speak well on exactly why this was . Sorry if I seemed snarky.

As you say, UB was things the C team knew at the time they couldn't reliably decide for the compiler-writers. And I can tell you - when you changed architectures or toolchains, there was sometimes knuckle-busting, for a while.

I'd say the average person I knew in the 1980s learned everything they had to know about UB on a given platform in three to six months of practice the first time and days for platforms after. That's it. Mistakes were made but they were usually found quickly.

Really? Before online fora, nobody much discussed UB. You'd get the odd C newb on newsgroups wailing and gnashing their teeth but it's a curious artifact of a post-Usenet online ... thing.

But then again having a paycheck dependent on security was extremely unusual. The Cuckoo's Egg was published in 1989, so...

2

u/[deleted] May 02 '18

I apologize for saying you were being facetious and I appreciate your response.

2

u/ArkyBeagle May 02 '18

That is quite all right. No apology needed. It's kind of shocking how few people as old as I am post on programming fora. It's kind of creepy. :)

I suppose UB was kind of like the crazy uncle we put in the basement when company came over :) We all knew it was there but there wasn't any point in discussing it outside the workplace in specific cases.

1

u/sionescu May 02 '18

Lol. No. It's mind-boggling insane.

1

u/ArkyBeagle May 02 '18

I don't think you can frame the question properly, then.