This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: cannot pass objects of non-POD type


On 10/24/07, Joe Buck <Joe.Buck@synopsys.com> wrote:
> So GCC could support this case and treat the warning as a pedwarn.

Well pedwarn is wrong as the code is just undefined at runtime (not at
compile time), pedwarn is for errors when the error is very pedantic.

Also he wants to do printf("%s", struct_containing_charptr);  which is
undefined at that point anyways.  Even for PODs.  He will get a
warning with -Wformat about that being undefined.  Yes we follow the
IA64 C++ ABI but we also want people to produce portable code.  You
never know some future GCC supports a different C++ ABI which says the
layout is different and then someone goes and tries to do this and
they get the incorrect result.  This is the idea of the warning here
really.  If you do:

struct b : String
{
 virtual void f();
};

struct b c;

void g(char*, ...);

void f(void)
{
  g("%s", c);
}

What exactly does that mean?  Do we pass it as a String or as a "b"?
This is the reason why non-POD through variable arguments is
undefined.

Thanks,
Andrew Pinski


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]