Re: copy constructors and printf
From: Dave Moore (dtmoore_at_rijnh.nl)
Date: 04/29/04
- Next message: Richard Jones: "Summer School on Garbage Collection & Memory Management"
- Previous message: Pat: "int64 question"
- In reply to: Rob Williscroft: "Re: copy constructors and printf"
- Next in thread: Rob Williscroft: "Re: copy constructors and printf"
- Reply: Rob Williscroft: "Re: copy constructors and printf"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 29 Apr 2004 09:00:28 -0700
Rob Williscroft <rtw@freenet.co.uk> wrote in message news:<Xns94D9AEB29866BukcoREMOVEfreenetrtw@130.133.1.4>...
> Dave Moore wrote in news:306d400f.0404280144.22bd8d7@posting.google.com
> in comp.lang.c++:
>
> > "John Harrison" <john_andronicus@hotmail.com> wrote in message
> > news:<c6m7pc$dir2s$1@ID-196037.news.uni-berlin.de>...
> >> "Sam Wilson [Bentley]" <sam.wilson@bentley.com> wrote in message
> >> news:408E8107.724EB6EE@bentley.com...
> >> > If you pass a C++ object by value as an argument to a function
> >> > which has
> >> >
> >> > a variable-length argument list (...), the MSVC7 C++ compiler does
> >> > not call the object's copy constructor and will not complain if the
> >> > copy constructor is private.
> >> >
> >> > 1) Is this part of the C++ language definition? What is the
> >> > thinking behind it?
> >>
> >> Kind of, the C++ standard just says that such behaviour is undefined.
> >>
> >
> > Please cite chapter and verse from the Standard when making such
> > assertions. In this case I think you are incorrect ... the rules for
> > arguments without parameters (5.2.2/7) don't say anything explicit
> > about the copy constructor. Basically they imply that an rvalue
> > argument that has class type will be used "as-is" ... which I assume
>
> This makes no sense at all, how can an rvalue (or anything else for that
> matter) be passed without copying ?
Well, I guess I see your point, but then how is a pass-by-value
argument of POD-type handled in a variadic function call? In Jerry
Coffin's response to my post in this thread, he said that a ctor
should be called "to initialize the parameter", but as I understand it
from 5.2.2/7 (which IMO is kind of vague here), there *is* no
parameter in a variadic function call (for arguments matching the ...
anyway), only an argument. So is my statement below about deferring
the copy constructor until the va_arg call correct?
> > to mean that the call to the copy constructor is deferred until the
> > call to va_arg in the function body.
OTOH, maybe there is some effect of the statement " .. lvalue to
rvalue conversion ... will be performed" in 5.2.2/7 that I am not
seeing? I would say that a POD-type object passed by value is an
rvalue, but I remember seeing somewhere in the Standard (I can't find
it anymore) that objects of class type are always passed to functions
as lvalues.
Please help me out of my confusion.
TIA, Dave Moore
P.S. I expect there is more info on this in the C-Standard, but I
don't have a copy of that.
- Next message: Richard Jones: "Summer School on Garbage Collection & Memory Management"
- Previous message: Pat: "int64 question"
- In reply to: Rob Williscroft: "Re: copy constructors and printf"
- Next in thread: Rob Williscroft: "Re: copy constructors and printf"
- Reply: Rob Williscroft: "Re: copy constructors and printf"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|