r208702 - No longer triggering a checked iterator assert on Windows when using std::copy while deserializing attributed statements with more than one attribute.

Aaron Ballman aaron at aaronballman.com
Tue May 13 08:39:36 PDT 2014


On Tue, May 13, 2014 at 11:35 AM, David Blaikie <dblaikie at gmail.com> wrote:
> On Tue, May 13, 2014 at 7:55 AM, Aaron Ballman <aaron at aaronballman.com> wrote:
>> Author: aaronballman
>> Date: Tue May 13 09:55:01 2014
>> New Revision: 208702
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=208702&view=rev
>> Log:
>> No longer triggering a checked iterator assert on Windows when using std::copy while deserializing attributed statements with more than one attribute.
>
> I have to say I don't quite follow where the checked failure would be
> in the original code. Could you explain it?

MSVC has an overload for std::copy that deduces array sizes for the
destination argument. So const Attr *Attrs[1] was always being deduced
as an array of a single element. Any time std::copy would be called
where end - begin > 1, the check would assert, even though there was
space allocated properly in practice. My change was simply to remove
the array bounds (well, the entire member variable, since it wasn't
needed anyway), so that array bounds could not be automatically
deduced.

~Aaron



More information about the cfe-commits mailing list