This is the mail archive of the
mailing list for the GCC project.
Re: cannot pass objects of non-POD type
- From: "Andrew Pinski" <pinskia at gmail dot com>
- To: "John Gateley" <gateley at jriver dot com>
- Cc: gcc at gcc dot gnu dot org
- Date: Wed, 24 Oct 2007 12:03:38 -0700
- Subject: Re: cannot pass objects of non-POD type
- References: <firstname.lastname@example.org>
On 10/24/07, John Gateley <email@example.com> 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
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).