[boost] Re: dangerous_cast<>

2002-12-04 Thread Eric Woodruff
[snip] > holder h; > new (h.storage) Foo; What is the meaning of that syntax? >... > T* u = dangerous_cast(h.storage); // can't do this with reinterpret_cast Why would you want to do that in the first place. > > HTH, > -- >David Abrahams >[EMAIL PROTECTED] * htt

[boost] Re: dangerous_cast<>

2002-12-04 Thread Eric Woodruff
"Gabriel Dos Reis" <[EMAIL PROTECTED]> wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > "David B. Held" <[EMAIL PROTECTED]> writes: > > | Does this have any merit whatsoever? > | > | template > | T* dangerous_cast(U* p) > | { > | return static_cast(static_cast(p)); > | } > > Is

[boost] Re: dangerous_cast<>

2002-12-04 Thread David B. Held
"Eric Woodruff" <[EMAIL PROTECTED]> wrote in message aslbsn$nt3$[EMAIL PROTECTED]">news:aslbsn$nt3$[EMAIL PROTECTED]... > [snip] > > > holder h; > > new (h.storage) Foo; > > What is the meaning of that syntax? This is placement new syntax. It means construct a Foo at the address h.storage, withou

[boost] Re: dangerous_cast<>

2002-12-04 Thread Eric Woodruff
"David B. Held" <[EMAIL PROTECTED]> wrote in message aslftb$cr2$[EMAIL PROTECTED]">news:aslftb$cr2$[EMAIL PROTECTED]... > "Eric Woodruff" <[EMAIL PROTECTED]> wrote in message > aslbsn$nt3$[EMAIL PROTECTED]">news:aslbsn$nt3$[EMAIL PROTECTED]... > > [snip] > > > > > holder h; > > > new (h.storage) F

[boost] Re: dangerous_cast<>

2002-12-04 Thread David B. Held
"Eric Woodruff" <[EMAIL PROTECTED]> wrote in message asli92$oqn$[EMAIL PROTECTED]">news:asli92$oqn$[EMAIL PROTECTED]... > [...] > > > > holder h; > > > > new (h.storage) Foo; > [...] > So the type really is of Foo, > [...] No, the type really is char[sizeof(T)] converted to char* const. Since the

[boost] Re: dangerous_cast<>

2002-12-04 Thread David B. Held
"Gabriel Dos Reis" <[EMAIL PROTECTED]> wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > David Abrahams <[EMAIL PROTECTED]> writes: > > | [...] > | if is_pointer and is_pointer > | return (dest_type)( > | (unisgned)src > | ^ sizeof

[boost] Re: dangerous_cast<>

2002-12-04 Thread David B. Held
"Gabriel Dos Reis" <[EMAIL PROTECTED]> wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > [...] > What do mean exactly by a "valid Foo*"? Hmm...I think 5.2.10/7 is more relevant. I guess it depends on what "unspecified" means. I assumed that it meant that you have a Foo*, but it mig

[boost] Re: dangerous_cast<>

2002-12-05 Thread Eric Woodruff
(inline) "Anthony Williams" <[EMAIL PROTECTED]> wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... [snip] > Gabriel Dos Reis writes: > unsigned char* has _additional_ properties to void* --- you can access the > object representation of _any_ object through an unsigned char* (and for P

[boost] Re: dangerous_cast<>

2002-12-05 Thread Anthony Williams
Eric Woodruff writes: > "Anthony Williams" <[EMAIL PROTECTED]> wrote in > message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > > Thus, given that h.storage is properly aligned, (which is the purpose of > the > > other union member), after "new(h.storage) Foo", h.storage contains a Foo > > o

[boost] Re: dangerous_cast<>

2002-12-05 Thread Eric Woodruff
"Anthony Williams" <[EMAIL PROTECTED]> wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > Eric Woodruff writes: > > "Anthony Williams" <[EMAIL PROTECTED]> wrote in > > message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > > > Thus, given that h.storage is properly aligned, (which

[boost] Re: dangerous_cast<>

2002-12-07 Thread Gennaro Prota
On 07 Dec 2002 12:26:35 +0100, Gabriel Dos Reis <[EMAIL PROTECTED]> wrote: >5.2.10/1: > The result of the expression reinterpret_cast(v) is the result of > converting the expression v to type T. [...] Are you saying you really understand what that phrase means? Can you explain it, and say plea

[boost] Re: dangerous_cast<>

2002-12-07 Thread Gennaro Prota
On Sat, 07 Dec 2002 17:16:42 +0100, Gennaro Prota <[EMAIL PROTECTED]> wrote: >On 07 Dec 2002 12:26:35 +0100, Gabriel Dos Reis ><[EMAIL PROTECTED]> wrote: > > >>5.2.10/1: >> The result of the expression reinterpret_cast(v) is the result of >> converting the expression v to type T. [...] > >Are yo

[boost] Re: dangerous_cast<>

2002-12-08 Thread Gennaro Prota
On 07 Dec 2002 21:16:49 +0100, Gabriel Dos Reis <[EMAIL PROTECTED]> wrote: >Do you mean it is invalid to reinterpret_cast<> to void*? Well, I'm not sure. 5.2.10/7: "A pointer to an object can be explicitly converted to a pointer to an object of different type.65) Except that converting an rva

[boost] Re: dangerous_cast<>

2002-12-08 Thread Gennaro Prota
On 08 Dec 2002 15:09:32 +0100, Gabriel Dos Reis <[EMAIL PROTECTED]> wrote: >Gennaro Prota <[EMAIL PROTECTED]> writes: > >[...] > >| If void* is not a "pointer to an object" then reinterpret_cast >| is invalid. Otherwise it just yields an undefined result. I should have said "unspecified", sorry.

[boost] Re: dangerous_cast<>

2002-12-08 Thread Gennaro Prota
--- Gabriel Dos Reis <[EMAIL PROTECTED]> wrote: > I'm not saying I hold the truth. I'm offering my reading, just as others > are doing. Yeah, that's ok. I meant: it's unlikely that we can really find a quote from the standard that says the last word here. Maybe the intent was to make reinterpre

[boost] Re: dangerous_cast<>

2002-12-08 Thread Gennaro Prota
On Sun, 08 Dec 2002 13:16:24 -0700, Greg Colvin <[EMAIL PROTECTED]> wrote: >It may be time to post a question to [EMAIL PROTECTED] Thank you very much. What is that? An internal list for the C++ committee? Is it open to everybody, or you meant that *you* are going to post a question there? Genny

[boost] Re: dangerous_cast<>

2002-12-09 Thread Anthony Williams
Gennaro Prota writes: > On 08 Dec 2002 15:09:32 +0100, Gabriel Dos Reis > <[EMAIL PROTECTED]> wrote: > > >Gennaro Prota <[EMAIL PROTECTED]> writes: > > > >[...] > > > >| If void* is not a "pointer to an object" then reinterpret_cast > >| is invalid. Otherwise it just yields an undefined r

Re: [boost] Re: dangerous_cast<>

2002-12-04 Thread Gabriel Dos Reis
"Eric Woodruff" <[EMAIL PROTECTED]> writes: | [snip] | | > holder h; | > new (h.storage) Foo; | | What is the meaning of that syntax? placement-new: Construct a Foo at h.storage. -- Gaby ___ Unsubscribe & other changes: http://lists.boost.org/mailma

Re: [boost] Re: dangerous_cast<>

2002-12-04 Thread Gabriel Dos Reis
"David B. Held" <[EMAIL PROTECTED]> writes: | Because you want to get at the T in h in a portable way. Which brings | me to my next point. Since it seems this is the only context in which this | cast is guaranteed to give a meaningful result, maybe it should be called | placement_cast<>? But th

Re: [boost] Re: dangerous_cast<>

2002-12-04 Thread David Abrahams
"Eric Woodruff" <[EMAIL PROTECTED]> writes: > "David B. Held" <[EMAIL PROTECTED]> wrote in message > aslftb$cr2$[EMAIL PROTECTED]">news:aslftb$cr2$[EMAIL PROTECTED]... >> "Eric Woodruff" <[EMAIL PROTECTED]> wrote in message >> aslbsn$nt3$[EMAIL PROTECTED]">news:aslbsn$nt3$[EMAIL PROTECTED]... >> >

Re: [boost] Re: dangerous_cast<>

2002-12-04 Thread Gabriel Dos Reis
"David B. Held" <[EMAIL PROTECTED]> writes: | "Eric Woodruff" <[EMAIL PROTECTED]> wrote in message | asli92$oqn$[EMAIL PROTECTED]">news:asli92$oqn$[EMAIL PROTECTED]... | > [...] | > > > > holder h; | > > > > new (h.storage) Foo; | > [...] | > So the type really is of Foo, | > [...] | | No, the ty

Re: [boost] Re: dangerous_cast<>

2002-12-04 Thread Gabriel Dos Reis
David Abrahams <[EMAIL PROTECTED]> writes: | "Eric Woodruff" <[EMAIL PROTECTED]> writes: | | > "David B. Held" <[EMAIL PROTECTED]> wrote in message | > aslftb$cr2$[EMAIL PROTECTED]">news:aslftb$cr2$[EMAIL PROTECTED]... | >> "Eric Woodruff" <[EMAIL PROTECTED]> wrote in message | >> aslbsn$nt3$[EMA

Re: [boost] Re: dangerous_cast<>

2002-12-04 Thread David Abrahams
Gabriel Dos Reis <[EMAIL PROTECTED]> writes: > David Abrahams <[EMAIL PROTECTED]> writes: > > | "Eric Woodruff" <[EMAIL PROTECTED]> writes: > | > | > "David B. Held" <[EMAIL PROTECTED]> wrote in message > | > aslftb$cr2$[EMAIL PROTECTED]">news:aslftb$cr2$[EMAIL PROTECTED]... > | >> "Eric Woodruff

Re: [boost] Re: dangerous_cast<>

2002-12-04 Thread Gabriel Dos Reis
"David B. Held" <[EMAIL PROTECTED]> writes: | "Gabriel Dos Reis" <[EMAIL PROTECTED]> wrote in message | [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... | > [...] | > What do mean exactly by a "valid Foo*"? | | Hmm...I think 5.2.10/7 is more relevant. I guess it depends on what | "unspecified" means

Re: [boost] Re: dangerous_cast<>

2002-12-04 Thread Gabriel Dos Reis
David Abrahams <[EMAIL PROTECTED]> writes: | Gabriel Dos Reis <[EMAIL PROTECTED]> writes: | | > David Abrahams <[EMAIL PROTECTED]> writes: | > | > | "Eric Woodruff" <[EMAIL PROTECTED]> writes: | > | | > | > "David B. Held" <[EMAIL PROTECTED]> wrote in message | > | > aslftb$cr2$[EMAIL PROTECTED]

Re: [boost] Re: dangerous_cast<>

2002-12-04 Thread Gabriel Dos Reis
"David B. Held" <[EMAIL PROTECTED]> writes: | "Gabriel Dos Reis" <[EMAIL PROTECTED]> wrote in message | [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... | > David Abrahams <[EMAIL PROTECTED]> writes: | > | > | [...] | > | if is_pointer and is_pointer | > | return (dest_type)( | > |

Re: [boost] Re: dangerous_cast<>

2002-12-04 Thread David Abrahams
Gabriel Dos Reis <[EMAIL PROTECTED]> writes: > Thanks for your patience. > > Now, imagine an implementation where the original type is remembered, > then dereferencing the pointer obtained from > >char* -> void* -> T* > > may just eject you into the outer space. Is remembering the original ty

Re: [boost] Re: dangerous_cast<>

2002-12-04 Thread Gabriel Dos Reis
David Abrahams <[EMAIL PROTECTED]> writes: | Gabriel Dos Reis <[EMAIL PROTECTED]> writes: | | > Thanks for your patience. | > | > Now, imagine an implementation where the original type is remembered, | > then dereferencing the pointer obtained from | > | >char* -> void* -> T* | > | > may just

Re: [boost] Re: dangerous_cast<>

2002-12-07 Thread Gabriel Dos Reis
"Eric Woodruff" <[EMAIL PROTECTED]> writes: [...] | > Thus, given that h.storage is properly aligned, (which is the purpose of | the | > other union member), after "new(h.storage) Foo", h.storage contains a Foo | > object. Thus accessing it through a pointer-to-Foo is legal, as Foo is the | > dyn

Re: [boost] Re: dangerous_cast<>

2002-12-07 Thread Gabriel Dos Reis
Gennaro Prota <[EMAIL PROTECTED]> writes: [...] | Well, in fact those subsequent paragraphs intentionally give very few | guarantee, and reinterpret_cast is exactly one of the cases | which are left unspecified (the guarantee of 5.2.10/7 concerns casting | to pointers to *object types*). So I gue

Re: [boost] Re: dangerous_cast<>

2002-12-07 Thread Gennaro Prota
--- Gabriel Dos Reis <[EMAIL PROTECTED]> wrote: > Gennaro Prota <[EMAIL PROTECTED]> writes: > > [...] > > | Well, in fact those subsequent paragraphs intentionally give very few > | guarantee, and reinterpret_cast is exactly one of the cases > | which are left unspecified (the guarantee of 5.2.1

Re: [boost] Re: dangerous_cast<>

2002-12-07 Thread Gabriel Dos Reis
Gennaro Prota <[EMAIL PROTECTED]> writes: | --- Gabriel Dos Reis <[EMAIL PROTECTED]> wrote: | > Gennaro Prota <[EMAIL PROTECTED]> writes: | > | > [...] | > | > | Well, in fact those subsequent paragraphs intentionally give very few | > | guarantee, and reinterpret_cast is exactly one of the case

Re: [boost] Re: dangerous_cast<>

2002-12-08 Thread Gabriel Dos Reis
Gennaro Prota <[EMAIL PROTECTED]> writes: [...] | If void* is not a "pointer to an object" then reinterpret_cast | is invalid. Otherwise it just yields an undefined result. I haven't | found a definition of "pointer to object" in the standard; anyhow | certainly void is not an object type. void*

Re: [boost] Re: dangerous_cast<>

2002-12-08 Thread Gabriel Dos Reis
Gennaro Prota <[EMAIL PROTECTED]> writes: [...] | > I haven't | >| found a definition of "pointer to object" in the standard; anyhow | >| certainly void is not an object type. | > | >void* is the generic type of "pointer to object." | | Well, as I said I don't find any definition of the expressi

Re: [boost] Re: dangerous_cast<>

2002-12-08 Thread Gabriel Dos Reis
Gennaro Prota <[EMAIL PROTECTED]> writes: [...] | > | In any case, do you agree that at least the | > | result is unspecified? | > | > I don't think I agree with this part; at least if it means anything | > other that converting a Foo* to void*. | | Well, then I don't think we can establish "th

Re: [boost] Re: dangerous_cast<>

2002-12-08 Thread Greg Colvin
It may be time to post a question to [EMAIL PROTECTED] At 12:59 PM 12/8/2002, you wrote: >--- Gabriel Dos Reis <[EMAIL PROTECTED]> wrote: > >> I'm not saying I hold the truth. I'm offering my reading, just as others >> are doing. > >Yeah, that's ok. I meant: it's unlikely that we can really find

Re: [boost] Re: dangerous_cast<>

2002-12-08 Thread Gabriel Dos Reis
I'll raise the issue the committee reflector. Gennaro Prota <[EMAIL PROTECTED]> writes: [...] | > | char * p = ... | > | reinterpret_cast(p) | > | | > | is illegal, because the sentence above talks about conversion to *a | > | different* type. And the conversions that are not listed cannot

Re: [boost] Re: dangerous_cast<>

2002-12-09 Thread Beman Dawes
At 03:53 PM 12/8/2002, Gennaro Prota wrote: >On Sun, 08 Dec 2002 13:16:24 -0700, Greg Colvin ><[EMAIL PROTECTED]> wrote: > >>It may be time to post a question to [EMAIL PROTECTED] > >Thank you very much. What is that? An internal list for the C++ >committee? Is it open to everybody, or you meant t

Re: [boost] Re: dangerous_cast<>

2002-12-09 Thread Greg Colvin
At 02:58 PM 12/9/2002, you wrote: >At 03:53 PM 12/8/2002, Gennaro Prota wrote: > >>On Sun, 08 Dec 2002 13:16:24 -0700, Greg Colvin >><[EMAIL PROTECTED]> wrote: >> >>>It may be time to post a question to [EMAIL PROTECTED] >> >>Thank you very much. What is that? An internal list for the C++ >>committ