This is the mail archive of the gcc-patches@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] |
Thats interesting, I hadn't seen that before. Interestingly, that would forbid this vector from ever extending or being passed by value to a function. However I assume here the copying in question is some kind of internal copying (I'm not an expert on the problem in question, but I assume that static elements are defined in some kind of data block, and then copied out of it?)
But copying singular iterators is explicitly disallowed, isn't it?
24.1/5: Iterators can also have singular values that are not associated with any container. [Example: After the declaration of an uninitialized pointer x (as with int* x;), x must always be assumed to have a singular value of a pointer. ] Results of most expressions are undefined for singular values; the only exception is an assignment of a nonsingular value to an iterator that holds a singular value. In this case the singular value is overwritten the same way as any other value.
This explicitly mentions the case of uninitialised pointers being singular.
Hmm.. I would tend to say the "C++" way was to never default initalise anything unless you have to. However I noticed vector<>::iterator and others default initalise, so I'll go with whatever more knowledgeable say.copying an unassigned pointer, and I don't see what advantage is gained by assigning the pointer, and the obvious (possibly slight) disadvantage is that now we have an extra assignment.
We have a default-initialisation (to zero in this case), rather than an
indeterminate value. IMHO any slight overhead is worth it.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |