News for hackers. Stuff that matters.
Re:Undefined behavior is often a thing for C programmers (2011) by bluetomcat on Thursday September 03, 2020 @11:19AM (#24364866)
UB is blown out of proportion by compiler vendors and language-lawyer types concerned with portability across exotic ranges of machines, including those, where, for example, CHAR_BIT != 8.

For the most part, avoiding UB is common sense when you grasp the basic abstract C memory model - types of storage and their lifetime, avoiding out of bounds array access, keeping track of the lifetime of all allocations, etc.

Re:Undefined behavior is often a thing for C programmers (2011) by srtjstjsj on Thursday September 03, 2020 @08:47PM (#24370635)
That's not the issue. The issue that simple bugs become global program transformations into nonsense due to aggressive optimizations, when they should instead be compile-time errors.
Re:Undefined behavior is often a thing for C programmers (2011) by armitron on Thursday September 03, 2020 @11:22PM (#24371413)
It's actually a big problem and anything but common sense.

Do all C programmers know what strict aliasing means?

How about pointer provenance?

Have they memorized integer promotion rules?

These are all potential sources of undefined behavior that can lead to catastrophic results.

I bet most experienced C programmers with decades under their belt would fail one or more of these tests.