"Gerhard Fiedler" <> wrote in message
news:47hao38wygfk$....
> Paul wrote:
>
>> What is undefined about the normal function I posted ref:
>>
>> void ordinaryfunction(p_obj){
>> overwrite(p_obj); /*overwrite the object p_obj points to*/
>> ordinaryfunction();
>> }
>
> In an earlier incarnation of this you specifically used assembly to
> overwrite p_obj in overwrite(). This is of course undefined behavior.
>
What is undefined about it?
The function is defined as:
a function that overwrites the memory the 'this' or 'p_obj' points to.
> If you want to get anywhere with this argument, you'd have to start
> using standard-conformant, compilable C++. The above is neither.
>
Can you show me an example where an ordinary function is the same as a
member function, using standard code?
If we were using only standard code then their argument wouldn't get off the
starting blocks.
> How exactly will you "overwrite" the class instance at p_obj?
>
That doesn't matter it, has no impact on the calling mechanics of the
recursive function. All we need to know is that the object is erased from
memory and no longer exists.
It has been overwritten, wiped out.
> Try to come up with a standard C++ example that involves a class and a
> function operating on an instance of that class. I'm pretty sure that it
> is possible to re-write that example using a member function. And vice
> versa.
Its uneccessary as the way in which the object is overwritten has no effect
on the calling mechanism.
Why don't you do it , give me one example of how to overwrite memory for
each memory model possible on a x86, thats about 8 different examples to
cover all x86 implementations. If you have a spare day or two please try to
create such a function that will keep everyone happy.
>
>> I used an example which made a new object in the same memory location,
>>ko with a theoretical asm routine. The reason I did it this way was to
>> emphasise the fact that the 'this' pointer was not even being
>> adjusted.[Note: Because I had the feleling someone would try to be
>> unreasonable and expect my code to comply with standards whereas the
>> other argument didn't comply, so I did it a way that my code *did
>> comply* anyway.. End note]
>
> As long as we're talking about C++, we should stick to the C++ standard
> -- or else what language are you /really/ talking about?
>
I think the C++ standard is not applicable for discussing function calling
mechanisms.
As I said he other argument wouldn't even get of the starting blocks if we
were sticking to the standards.
>> Are you saying its illegal to overwrite an object? Please make your point
>> clear.
>
> It's not; we have assignment operators for that. It is you who is trying
> to make a point that it's not possible to overwrite a class instance.
Assignment operator modifies an object it doesn't overwrite it with a
completely new object.
>
>> Before straying too far form the original subject please note that if
>> my ordinary function is valid C++ code ...
>
> But so far it isn't. You have to do more work on this.
>
It's perfectly valid in C++ to call an asm routine.
You seem to want to create an abstract discussion about the way in which an
objects memory is overwritten. This makes no difference to the point I was
making about the ivocation of the function.