Note that the word in the book is "synthesized", not
"generated". But I think the difference is more one of context;
the book is talking about what the compiler does: in the case of
a trivial constructor, the compiler doesn't do anything. From a
language point of view, there is a constructor, but it doesn't
result in any code, which is what Lippman is talking about.
Where *what* says that? The standard? The book?
An implicitly declared default c-tor is implicitly defined for
a class. There seems to be no clear connection between the
terms "non-trivial" and "implicitly defined".
It seems very clear to me: if the class meets certain criteria,
the implicitly defined constructor is trivial. By definition,
no explicitly defined constructor (even one with an empty inline
body) is trivial. The set of all trivial constructors is a
subset of the set of all implicitly defined constructors.
"Trivial" is used to define the lifetime of
objects and the behaviour of 'delete', for example.
Trivial has nothing to do with the lifetime of objects. It is a
categoristic of default constructors, copy constructors, copy
assignment operators and destructors. Whether are trivial
authorizes some other operations: they all must be trivial, for
example, if the type is to be a member of a union.
Triviality is relevant to lifetime only in so far that if the
constructor is trivial, lifetime of the object is considered to
start as soon as the memory for it is allocated, and if the
destructor is trivial, lifetime of the object is considered to
last until the memory is freed or reused.
"Implicitly defined" sets forth certain relation between the
type and its bases and members (bases should have their
implicitly declared c-tors implicitly defined if this class
has its c-tor implicitly defined).
I don't think so. A special member function is implicitly
defined if it is implicitly declared and is used. It is
implicitly declared if the user hasn't explicitly declared it,
and in the case of a default constructor, if the user hasn't
explicitly declared any other constructor.
However, it's every author's right to draw parallels or make
guesses as to what the Standard actually means. Considering
that Lippman is one of the authorities in C++, he probably
knows what he's talking about if from his text it seems
apparent that "non-trivial" and "implicitly defined" and
"generated" all mean basically the same thing.
Actually, the quoted text is a lot more precise than that. It
speaks of when the compiler "synthesizes" a default constructor.
The standard never uses the word "synthesize", and from the name
of the book, I'm pretty sure the Lippman is talking about
compiler internals here---when does the compiler generate code
on its own for the constructor.
The answer is, of course, whenever the constructor is implicitly
declared, is used, and is not trivial. The definition of
"trivial", in the standard, is designed intentionally so that
the compiler implementation can do nothing in the case of a
trivial default constructor or a trivial destructor, and can do
a bitwise copy in the case of a trivial copy constructor or a
trivial assignment operator.
I disagree with his disagreement. A compiler very well could
generate the constructor like this. It's not required, however,
and none that I use do.
OK. I thought you disagreed with something I posted since you
replied to my post and not to the one you disagreed with.
As I can see, you quoted part of the Standard that explains
that it is incorrect to expect zero-initialisation of POD
members by the implicitly defined constructor. I agree.
It is, in fact, undefined behavior if you even read the values
(except if you read them as a character type).