C++ Logo

std-proposals

Advanced search

Re: [std-proposals] dynamic_cast<void*>(void*)

From: Frederick Virchanza Gotham <cauldwell.thomas_at_[hidden]>
Date: Mon, 26 Feb 2024 11:53:01 +0000
On Mon, Feb 26, 2024 at 11:43 AM Andrey Semashev wrote:
>
> dynamic_cast from void* to void* is currently well-defined.


I don't see that in the C++ Standard. The following 4 compilers complain:


Microsoft
    the operand of a pointer dynamic_cast must be a pointer to a
complete class type
GNU g++
    cannot 'dynamic_cast' 'v' (of type 'void* const') to type 'void*'
(source is not a pointer to class)
LLVM clang++
    'void' is not a class type
Intel ICX
    'void' is not a class type

Just now I tried the same code on Microsoft Visual Studio 2022, and it
crashes. I'm not sure if it's also possible with the Microsoft ABI --
I'll read up on the Microsoft layout of vtables and try code it.

Received on 2024-02-26 11:53:13