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.
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.