In the following code:
#include <cstddef>class s;void foo(void* buffer) { using s_ptr = s *; const auto b_s = reinterpret_cast<const s_ptr>(buffer); const auto b_s2 = reinterpret_cast<const s *>(buffer); }
Compiling with -O3 -Werror=ignored-qualifiers
I got the error:
<source>: In function 'void foo(void*)':<source>:5:22: error: type qualifiers ignored on cast result type [-Werror=ignored-qualifiers] 5 | const auto b_s = reinterpret_cast<const s_ptr>(buffer); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Is this a bug in GCC? Shouldn't both reinterpret_cast
be the same?