[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: [ANN] Lua 5.2.1 (work1) now available
- From: Coda Highland <chighland@...>
- Date: Sat, 7 Apr 2012 11:29:17 -0500
On Sat, Apr 7, 2012 at 11:07 AM, Patrick Rapin <toupie300@gmail.com> wrote:
>> This HAS to be a reinterpret_cast because all casts through void* are
>> considered unsafe by the compiler.
>
> Sorry, but this is wrong.
> A compiler will generate error when using static_cast to convert
> between *unrelated* pointer types.
> The generic void* pointer is considered related with all T* pointers
> (without const or volatile qualifier).
> Also, the cast from A* to B* is accepted by static_cast if B derives
> from A (the other way round, converting B* to A* does not need any
> cast of course).
I'd still make it a reinterpret_cast even if the compiler allows it
because I disagree with the notion that void* is related. It really is
a reinterpretation of the pointer -- from a known type to an opaque
one. It's not becoming more or less specific like a static_cast would
imply; it's completely losing all of its type information. So spec or
not, the idea of what the casts are supposed to be makes void*
conceptually a reinterpret_cast even if the compiler allows
static_cast.
/s/ Adam
- References:
- Re: [ANN] Lua 5.2.1 (work1) now available, Miles Bader
- Re: [ANN] Lua 5.2.1 (work1) now available, Roberto Ierusalimschy
- Re: [ANN] Lua 5.2.1 (work1) now available, Miles Bader
- Re: [ANN] Lua 5.2.1 (work1) now available, Roberto Ierusalimschy
- Re: [ANN] Lua 5.2.1 (work1) now available, Miles Bader
- Re: [ANN] Lua 5.2.1 (work1) now available, Miles Bader
- Re: [ANN] Lua 5.2.1 (work1) now available, Roberto Ierusalimschy
- Re: [ANN] Lua 5.2.1 (work1) now available, Miles Bader
- Re: [ANN] Lua 5.2.1 (work1) now available, Miles Bader
- Re: [ANN] Lua 5.2.1 (work1) now available, Rena
- Re: [ANN] Lua 5.2.1 (work1) now available, Miles Bader
- Re: [ANN] Lua 5.2.1 (work1) now available, Coda Highland
- Re: [ANN] Lua 5.2.1 (work1) now available, Peter Cawley
- Re: [ANN] Lua 5.2.1 (work1) now available, Patrick Rapin
- Re: [ANN] Lua 5.2.1 (work1) now available, Coda Highland
- Re: [ANN] Lua 5.2.1 (work1) now available, Patrick Rapin