On Wed, Oct 24, 2007 at 01:37:25PM -0700, Andrew Pinski wrote: > On 10/24/07, Jack Lloyd <[EMAIL PROTECTED]> wrote: > > Is there a reason it's not just an error, then? (As a user) I don't > > see the point of something being a warning when the compiled code is > > intentionally set up to crash. > > Because the C++ standard (and the C standard) has mentioned that you > cannot diagnostic an undefined runtime behavior. So the code is valid > semantically but undefined at runtime.
But the way that the object is passed in this case, and the stack layout, are completely defined on any platform that obeys the cross-platform API you will find at http://www.codesourcery.com/cxx-abi/ and this definition specifies that everything will look exactly the same as if it were a POD with the same members declared in the same order. For that reason, while I'm not surprised by the warning message, I am surprised that the code crashes; it would seem to require extra work to make it do so. Not that I would support this particular programming style; varargs/stdargs gives up type safety and risks runtime errors.