News for hackers. Stuff that matters.
Re:C Questions and Answers by _RPM on Wednesday March 04, 2015 @12:08AM (#9142787)
This reminds me of tests I took in earlier CS classes. Knowing those things are utterly useless in practice.
Re:C Questions and Answers by gamegoblin on Wednesday March 04, 2015 @01:57AM (#9143052)
My CS101 prof would give 50-100 line blocks of code, and hidden in them somewhere would be something like:

    if(condition); {
        some stuff
    }
Note the semicolon after the if-statement.

The tests became games of "find the semicolon or = in place of ==". Ugh.

Re:C Questions and Answers by oneeyedpigeon on Wednesday March 04, 2015 @03:13AM (#9143214)
Thankfully, your compiler probably warns about this nowadays, making such pointlessness obsolete.
Re:C Questions and Answers by ygra on Wednesday March 04, 2015 @05:45AM (#9143563)
And the static analysis tool you're hopefully using.
Re:C Questions and Answers by cbsmith on Wednesday March 04, 2015 @03:00AM (#9143193)
A lot of these are cases where I've seen actual bugs. Popular ones are >= 0 checks, dumb assumptions about overflows and null derefs, and the always popular "use an int when it should be size_t".
Re:C Questions and Answers by bgvopg on Wednesday March 04, 2015 @12:37AM (#9142866)
What is your main programming language; in which you do most of the work?
Re:C Questions and Answers by _RPM on Wednesday March 04, 2015 @09:17AM (#9144291)
C, actually, at the moment. But I don't use C for work or web development.
Re:C Questions and Answers by bgvopg on Wednesday March 04, 2015 @04:39PM (#9147542)
I hope this thread gave you some idea how important these thing really are.
Re:C Questions and Answers by frozenport on Wednesday March 04, 2015 @01:43AM (#9143013)
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 by rtpg on Wednesday March 04, 2015 @02:23AM (#9143111)
only useless if you never make a mistake ever. This shows what you should be vigilant for (alternatively , an argument for using a language with more checks)

As someone on HN once said (in jest), it's easy to write bug-free C, you just need to never make a mistake ever and spend a million hours auditing it.

Re:C Questions and Answers by icebraining on Wednesday March 04, 2015 @04:40AM (#9143413)
If those mistakes are so teachable, wouldn't it be better to put them into a linter?
Re:C Questions and Answers by joosters on Wednesday March 04, 2015 @04:47AM (#9143433)
They are in linters, and many of them will be thrown up as warnings by the compiler in the first place.