std::merge() asserts with empty source ranges and null result pointer - by Avery Lee

Status : 

  Fixed<br /><br />
		This item has been fixed in the current or upcoming version of this product.<br /><br />
		A more detailed explanation for the resolution of this particular item may have been provided in the comments section.


1
1
Sign in
to vote
ID 683214 Comments
Status Closed Workarounds
Type Bug Repros 1
Opened 8/5/2011 6:41:51 PM
Access Restriction Public

Description

std::merge() throws an assertion in debug builds if the result pointer is null even if the source ranges are empty. This is a likely case for empty instances of a vector class that uses pointers as the iterator type.
Sign in to post a comment.
Posted by Microsoft on 4/28/2014 at 3:16 PM
Hi,

Thanks (yet again) for reporting this bug. We've fixed it, and the fix will be available in the next major version of VC.

We've audited all STL algorithms (in <algorithm>, <numeric>, and <memory>, including those defined in internal headers) to accept null iterators and null function pointers when permitted by the Standard. (We're being very strict about iterators, although slightly less strict for function pointers - in particular, there are algorithms taking input iterators which are said to invoke their functors for N >= 2 only. We permit null function pointers to be passed for N == 0, but complain for N == 1. I suspect nobody will ever notice this, but I'm mentioning it for completeness.)

I've also written an exhaustive regression test to ensure that we continue permitting [null, null) ranges and null outputs in the future. I don't believe there are any remaining problems, but if there are they will be isolated rather than systemic.

Stephan T. Lavavej
Senior Developer - Visual C++ Libraries
stl@microsoft.com
Posted by Microsoft on 2/21/2013 at 1:47 PM
Hi,

Thanks for reporting this bug. I wanted to let you know what's happening with it. I'm still keeping track of it, but it's been resolved as "Deferred" because we may not have time to fix it in VC12. (Note: VC8 = VS 2005, VC9 = VS 2008, VC10 = VS 2010, VC11 = VS 2012.)

Note: Connect doesn't notify me about comments. If you have any further questions, please E-mail me.

Stephan T. Lavavej
Senior Developer - Visual C++ Libraries
stl@microsoft.com
Posted by Microsoft on 6/18/2012 at 2:21 PM
Hi,

Thanks for reporting this bug. I'm Microsoft's maintainer of the STL, and I wanted to let you know that while this bug remains active in our database, it won't be fixed in VC11 RTM (VS 2012 RTM). All bugs are important to us, but some are more severe than others and rise to the top of our priority queue.

I'm copying-and-pasting this response across all of the STL's active Connect bugs, but the following terse comments apply specifically to your bug:

* I agree that the assertion is too aggressive - however, this is simply one occurrence of a widespread issue throughout the STL. We'll need to rework our assertion machinery so it understands that empty input ranges won't attempt to write to the output range.

I can't promise when we'll be able to resolve this bug, but we hope to do so as soon as possible (and I'll send another response when that happens) - our first opportunity will be the "out of band" release between VC11 and VC12 that Herb Sutter announced at the GoingNative 2012 conference.

Note: Connect doesn't notify me about comments. If you have any further questions, please E-mail me.

Stephan T. Lavavej
Senior Developer - Visual C++ Libraries
stl@microsoft.com
Posted by EricLeong [Feedback Moderator] on 8/7/2011 at 7:13 PM
Thank you for submitting feedback on Visual Studio 2010 and .NET Framework. Your issue has been routed to the appropriate VS development team for review. We will contact you if we require any additional information.
Posted by MS-Moderator01 on 8/5/2011 at 6:50 PM
Thank you for your feedback, we are currently reviewing the issue you have submitted. If this issue is urgent, please contact support directly(http://support.microsoft.com)