Live data from Hacker News

C Questions and Answers

kukuruku.co

1–10 of 135 posts

Re: C Questions and Answers

#4
Surprisingly accurate, author did his research.

5 is also missing a check for a NULL pointer. ;)

Most of there rules are unfortunately ignored, as obscure information. The worst offender I see in wild code is 5.

The second most ignored is not checking values before computation: 10, 11, 12.

No.7 is very interesting, rarely violated, most programmers don't even know that is a thing or just assume the processor won't trap on an unaligned read.

Re: C Questions and Answers

#5
He's discussing subtle points of the C language and yet there is no mention of which compiler he's using, whether the results might be different for different compilers, hardware platforms, and how they correlate with multiple C standards (C89, C99, C11/C1X, etc).

He succeeded in convincing me that he does not know C!

Re: C Questions and Answers

#6
post #5

He's discussing subtle points of the C language and yet there is no mention of which compiler he's using, whether the results might be different for different compilers, hardware platforms, and how they correlate with multiple C standards (C89, C99, C11/C1X, etc). He succeeded in convincing me that he does not know C!

There is no mention of which compiler he's using or whether the results might be different for different compilers and/or hardware platforms precisely because he's discussing the C language— not the idiosyncrasies of particular implementations.

>and how they correlate with multiple C standards

There's nothing going on here specific to any particular revision of ISO C (that I can see).

Re: C Questions and Answers

#8
post #2

This reminds me of tests I took in earlier CS classes. Knowing those things are utterly useless in practice.

Compilers are increasingly optimizing out UB, recently fixed a problem where `std::unique_lock` was optimized as it was referenced from an `std::thread` defined at the top of the class. The future is now!

Re: C Questions and Answers

#9
Well apparently I do know C. If the author wanted to be as contrived a possible there are certainly more devious edge cases which could have been trotted out. The fact that e.g. the compiler may optimize out a NULL check after you've already dereferenced the darn thing shouldn't be surprising. Just fix your silly bug.
Post reply on HN