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: -Wconversion versus libstdc++


Hi Gaby,

There is something that we knoq about the code, that the compiler
does not have: we expect a sequence denoted by its first and last
element, so that the difference is always positive.  However, the
difference of pointers is defined in the language as an ptrdiff_t (a
signed type).  No wonder what people invented ssize_t :-)

I believe we have to investigate further what promises we want make
and hold through max_size() and change the code according to that.


First, I want to tell you that I agree with your general point of view, here and elsewhere, in particular about the tension existing between difference_type and size_type: as a matter of fact, when, time ago, I noticed some differences between our vector and deque implementations, I wrote something about it in private mail to Howard, but we didn't pursue the issue much...

Coming to the specific issue, and *assuming* we agree about the usefulness of warning for signed -> unsigned, maybe we are "lucky", in this sense: Table 65 says *explicitely* that size_type can represent any non-negative value of difference_type. Thus, as I see the issue, we can safely cast from the latter to the former, if we want, without entering in the larger discussions mentioned above... What do you think?

Paolo.


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