Quantcast
Channel: Active questions tagged gcc - Stack Overflow
Viewing all articles
Browse latest Browse all 21994

Why does GCC handle a const reinterpret_cast different when type alias is used? [duplicate]

$
0
0

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?


Viewing all articles
Browse latest Browse all 21994

Trending Articles