This is the mail archive of the
mailing list for the GCC project.
Re: [patch] Make vector::at() assertion message more useful (try #2)
- From: Paolo Carlini <paolo dot carlini at oracle dot com>
- To: Paul Pluzhnikov <ppluzhnikov at google dot com>
- Cc: Daniel Krügler <daniel dot kruegler at gmail dot com>, gcc-patches List <gcc-patches at gcc dot gnu dot org>, libstdc++ <libstdc++ at gcc dot gnu dot org>
- Date: Fri, 13 Sep 2013 12:02:23 +0200
- Subject: Re: [patch] Make vector::at() assertion message more useful (try #2)
- Authentication-results: sourceware.org; auth=none
- References: <ye6qhae0qpf8 dot fsf at elbrus2 dot mtv dot corp dot google dot com> <CAGNvRgDfHf6pYmBYC66HHhj6RobhiaiAAVEKj1FDxSWGxbYFTg at mail dot gmail dot com> <CALoOobMf3u8R_DVW5b2eRy05fBpB5unhriLMYdUEkT_E3DwtaA at mail dot gmail dot com> <CAGNvRgD6mK=-n7QhK=-NtfXZHOpCniXKc-riWUNfqZeVa8xufQ at mail dot gmail dot com> <CALoOobO6XEsrSM6jJFCQ=n00iY8qM=eujs-=LixNZyuya5f-cA at mail dot gmail dot com>
On 09/13/2013 02:01 AM, Paul Pluzhnikov wrote:
On Wed, Sep 4, 2013 at 9:55 PM, Daniel Krügler
Did you mean "pessimises code size", or something else?
Daniel's idea proved a good one, and I now have a patch that I am
happy with, and that will be easy to extend to string::at(), and other
I've added the new snprintf.cc to c++11/ rather than c++98/ as Paolo
suggested, because the only current caller is in c++11/functexcept.cc
Patch looks pretty good to me. Thanks for persisting. Some details:
- The game with the variadic and the non-variadic __throw_out_of_range
makes me a little nervous. Let's just name the new one differently, like
- Please consistently use __builtin_alloca everywhere, alloca isn't a
- I would rather call the file itself snprintf_lite.cc, in order not to
fool somebody that it actually implements the whole snprintf.
- I'm a bit confused about __concat_size_t returning -1. Since it only
formats integers, I think we can be *sure* that the buffer is big
enough. Then, if it returns -1 something is going *very badly* wrong,
shouldn't we __builtin_abort() or something similar?
- In terms of buffer sizes, this comment:
// enough for expanding up to 5 size_t's in the format.
and then the actual code in __snprintf_lite makes me a little nervous.
Agreed, we are not going to overflow the buffer, but truncating with no
diagnostic whatsoever seems rather gross. We can probably sort out this
later, new ideas welcome, anyway.
- While we are at it, shouldn't we use the new facility at least in
array, vector<bool> and deque too? For consistency over the containers.