You can't dynamic cast something to void* because nothing inherits from void.
void is not a type, you can't have an object of type void, it's a place holder. dynamic_cast makes absolutely no sense, neither does static_cast.



From: Std-Proposals <std-proposals-bounces@lists.isocpp.org> on behalf of Frederick Virchanza Gotham via Std-Proposals <std-proposals@lists.isocpp.org>
Sent: Monday, February 26, 2024 12:53:20 PM
To: std-proposals@lists.isocpp.org <std-proposals@lists.isocpp.org>
Cc: Frederick Virchanza Gotham <cauldwell.thomas@gmail.com>
Subject: Re: [std-proposals] dynamic_cast<void*>(void*)

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.
--
Std-Proposals mailing list
Std-Proposals@lists.isocpp.org
https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals