Search

C++ Defect Report 445 Implementation by CornedBee

Closed
as Fixed Help for as Fixed

2
0
Sign in
to vote
Type: Bug
ID: 541226
Opened: 3/11/2010 6:24:25 AM
Access Restriction: Public
0
Workaround(s)
1
User(s) can reproduce this bug
The C++03 standard contains a defect regarding the specification of iterators and especially their nested types. Basically, the reference and pointer nested types were underspecified. This was reported as DR445 to the LWG.

Under the resolution, an iterator's reference and pointer nested types now have to be the return types of its operator* and operator->, respectively. As part of this change, the specification of istreambuf_iterator has changed to make reference equal to value_type.

This resolution was adopted for the committee draft of C++0x in 2008, but can be found in working papers as early as N1804, published 2005-05. Despite this, the resolution still has not been implemented in the Visual Studio 2010 standard library: std::istreambuf_iterator<Ch>::reference is still Ch&.

This may seem subtle, but one consequence of this is that it is not possible to instantiate Boost.Spirit's multi_pass iterator adapter with istreambuf_iterator. This is problematic, because using istream_iterator instead involves a performance hit (dereferencing an istream_iterator is far more expensive than an istreambuf_iterator) as well as subtly changed semantics (whitespace skipping leads to bugs that are very hard to track down).
Details (expand)

Product Language

English

Version

Visual Studio 2010 Release Candidate

Operating System

Windows Vista

Operating System Language

English

Steps to Reproduce

Attempt to instantiate Spirit's multi_pass with an istreambuf_iterator:

        typedef std::istreambuf_iterator<wchar_t> wisbuf_iterator;
        typedef boost::spirit::multi_pass<wisbuf_iterator,
            boost::spirit::iterator_policies::default_policy<
                boost::spirit::iterator_policies::ref_counted,
                boost::spirit::iterator_policies::no_check,
                boost::spirit::iterator_policies::input_iterator,
                boost::spirit::iterator_policies::split_std_deque
            >
        > input_iterator;
        std::wifstream stream("some file.txt");
        input_iterator first(stream), last;

Actual Results

A compilation error from the guts of Boost.Spirit, complaining that it can't convert const wchar_t (the result of some intermediate Spirit function which actually returns a const wchar_t&) to wchar_t& (the result of another intermediate Spirit function, specified to return the iterator's reference type).

Expected Results

If the reference type of the iterator was fixed according to the DR, the return type of the outer function would be wchar_t and the conversion would succeed.
(There's also a bug in Boost.Spirit here, but fixing it merely changes the location where the bug here manifests.)
      You can indicate your satisfaction with how Microsoft handled this issue by completing this quick 3 question survey. [Details]

 

File Attachments
0 attachments
Sign in to post a comment.
Posted by Microsoft on 11/1/2010 at 3:51 AM
Hi,

Thanks again for reporting this bug. We've fixed it, and the fix will be available in VC11.

As always, if you have any further questions, feel free to E-mail me at stl@microsoft.com .

Stephan T. Lavavej
Visual C++ Libraries Developer
Posted by Microsoft on 3/12/2010 at 3:46 PM
Hi,

Thanks for reporting this bug. Although it's too late to fix this in VC10 RTM, we're keeping it active so that it can be fixed in a future release.

Note that decltype can now be used to figure out the return type of a function without having to be told by typedefs.

If you have any further questions, feel free to E-mail me at stl@microsoft.com .

Stephan T. Lavavej
Visual C++ Libraries Developer
Posted by Microsoft on 3/12/2010 at 12:41 AM
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).
Sign in to post a workaround.