News for hackers. Stuff that matters.
Re:Two musings on the design of compiler warnings by nyanpasu64 on Wednesday September 02, 2020 @03:37PM (#24357094)
for (auto foo : list) assert(foo);

The problem is that the assert() macro disappears in release mode, causing foo to trigger an unused variable warning. You need to (void)foo; as well.

On a related note, since assert() is removed in release mode, assert(fn_with_side_effects()) will fail to run the function in release mode. You need to separate it into two lines.

Re:Two musings on the design of compiler warnings by syrrim on Wednesday September 02, 2020 @05:09PM (#24358170)
Should probably #define assert(x) to be ((void)x) for release builds instead.
Re:Two musings on the design of compiler warnings by saagarjha on Wednesday September 02, 2020 @05:35PM (#24358439)
Make sure to #undef assert before this, and then set NDEBUG and include assert.h again.