[patch] Make vector::at() assertion message more useful
Paolo Carlini
paolo.carlini@oracle.com
Sat Aug 17 10:41:00 GMT 2013
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.
Thanks,
Paolo
More information about the Libstdc++
mailing list