For example, as part of a container class: void remove_memory_blocks(pointer back_element_in_final_block) { if constexpr(!std::is_trivially_destructible<element_type>::value) { // destroy each element in each memory block until the back_element is reached } // remove memory blocks } If element_type is_trivially_destructible, G++ will warn that back_element_in_final_block is unused every time the function is called. Ideally this warning should be performed before constexpr blocks are removed by a parser (I have no idea what the procedure is for GCC, I'm just guessing here)
The warning is already fixed in the GCC 10 branch. N.B. if you have a loop that does nothing but run trivial destructors, GCC will optimize it out anyway. *** This bug has been marked as a duplicate of bug 81676 ***
Thank you - I'm aware GCC might optimize it out (and failed to test with GCC10), at least in O2 mode, but other compilers might not, hence the code.