This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: [patch] Make vector::at() assertion message more useful
- From: Gabriel Dos Reis <gdr at integrable-solutions dot net>
- To: Paolo Carlini <paolo dot carlini at oracle dot com>
- Cc: Paul Pluzhnikov <ppluzhnikov at google dot com>, "gcc-patches at gcc dot gnu dot org" <patches at gcc dot gnu dot org>, "libstdc++" <libstdc++ at gcc dot gnu dot org>, habets at google dot com
- Date: Sat, 17 Aug 2013 10:10:13 -0500
- Subject: Re: [patch] Make vector::at() assertion message more useful
- References: <ye6qk3jlqioo dot fsf at elbrus2 dot mtv dot corp dot google dot com> <920436ac-4138-4f62-81b3-1499ebf1211e at email dot android dot com>
On Sat, Aug 17, 2013 at 5:41 AM, Paolo Carlini <paolo.carlini@oracle.com> wrote:
>
>
> Hi,
>
> Paul Pluzhnikov <ppluzhnikov@google.com> ha scritto: __throw_out_of_range(__N("vector::_M_range_check"));
>>+ {
>>+ char __s[256];
>>+ __builtin_snprintf(__s, sizeof(__s),
>>+ __N("vector::_M_range_check: %zu >= %zu"),
>>+ __n, this->size());
>>+ __throw_out_of_range(__s);
>>+ }
>
> The idea makes sense, but while we are at it I think the message could be more clear, say what the two numbers are. Also, I don't think we can unconditionally call snprintf, it's C99 and supported targets lack it. Maybe with some libiberty magic? I don't think such magic automagically triggers when __builtin_snprintf is expanded, or does it? Please investigate that.
I agree that we can't embark a significant IO library as part of a purely
data structure components.
Furthermore, __builtin_snprintf doesn't always expand to a
compiler magic -- it can be a normal function call.
This would be a regression, not an improvement.
-- Gaby