[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: [ANN] Lua 5.2.1 (work1) now available
- From: liam mail <liam.list@...>
- Date: Sat, 7 Apr 2012 22:10:05 +0100
On 7 April 2012 20:20, Coda Highland <chighland@gmail.com> wrote:
>> Whether you agree of not does not really matter,static_cast is the
>> correct cast to use and the result of reinterpret_cast is mostly
>> implementation specific.
>
> No, it's quite well-defined: "Converting a prvalue of type “pointer to
> T1” to the type “pointer to T2” [...] and back to its original type
> yields the original pointer value." The fact that the C++03 spec
> doesn't make it clear that void* is allowed as T1 or T2 in this
> context is in fact an error and the C++11 spec corrects this (see
> defect 1120) -- and this is how every C++ compiler in common use does
> it. So reinterpret_cast'ing to void* and back is guaranteed safe.
>
> /s/ Adam
>
Arrr erm :)
Whilst this change is not in the last draft[1], as you said the
explicit operation is allowed by ISO C++11[2]. However the fact that
it is was not in any earlier standards would make it undefined in
those, as only casts which are listed are defined.
So yes it is valid in C++11 yet still invalid for the earlier
standards, with static_cast being correct in all standards.
[1] I am not even going to rant about how silly it is that only the drafts ....
[2] 1120 as noted by Coda
http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#1120
Liam
- 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
- Re: [ANN] Lua 5.2.1 (work1) now available, Coda Highland
- Re: [ANN] Lua 5.2.1 (work1) now available, liam mail
- Re: [ANN] Lua 5.2.1 (work1) now available, Coda Highland