On 10/24/07, John Gateley <[EMAIL PROTECTED]> wrote:
> The situation is this: I have a lot of code that uses a string class
> which takes advantage of the pun: the string class has only the
> one data member, which means you can do things like printf("%s", obj)
> and have the right thing happen (using a different compiler, of course).
> Is there any way to use this useful pun with g++?

This is way undefined code really.  The class is a non POD since you
have a private member.  And the C++ standard says it is undefined what
happens when you pass a non-POD for a varable arguments function (the
reasoning is due to virtual functions and knowning the full size of
the struct).

Also using %s with anything but a char* is undefined behavior anyways
(even if it is a struct that only contains a char* since the ABI could
say they are passed differently).

-- Pinski

Reply via email to