Home Dashboard Directory Help
Search

Library or compiler bug with Visual C++ 2010 by Mark Lacey [Intel]


Status: 

Active


1
0
Sign in
to vote
Type: Bug
ID: 552541
Opened: 4/19/2010 5:21:43 PM
Access Restriction: Public
0
Workaround(s)
view
1
User(s) can reproduce this bug

Description

I'm seeing an issue with a compilation error using Visual C++ 2010.

g++, clang++, and Comeau all compile this code without error.

Please advise on work-arounds that do not involve modifying the standard headers (if this is in fact a library bug). Modifying the local copy of the standard headers is not an option.
Details
Sign in to post a comment.
Posted by Microsoft on 11/1/2010 at 4:10 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 4/27/2010 at 11:53 AM
Hi,

Thanks for reporting this bug. The problem is that our implementation of std::set and the other associative containers provides perfect forwarding overloads of insert() which shouldn't exist. (They don't appear in any C++0x Working Paper, so it looks like we just got confused.) The perfect forwarding insert() attempts to construct ECValue from const BasicBlock * inside std::set, but that constructor is private, and ECValue didn't grant friendship to std::set.

We'll keep this bug open so that it can be fixed in VC11. In the meantime, changing:

return TheMapping.insert(Data).first;

to:

return TheMapping.insert(ECValue(Data)).first;

is a correct and simple workaround. This attempts to construct ECValue from const BasicBlock * inside EquivalenceClasses, which has been granted friendship.

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 Viorel_ on 4/21/2010 at 7:09 AM
See also: http://llvm.org/bugs/show_bug.cgi?id=6505.

The problem can be reproduced with a smaller non-template example:


#include <set>

class Outer
{
    class Inner
    {
        friend class Outer;

        int Value;

        Inner( const int & value ) : Value(value) {}

    public:
        bool operator < ( const Inner & other ) const
        {
            return Value < other.Value;
        }
    };

    std::set< Inner > Data;

public:
    void Insert( const int & value )
    {
        Data.insert( value ); // Error C2248
        // Workaround: Data.insert( Inner( value ));
    }
};

void test()
{
    Outer o;
    o.Insert( 2010 );
}
Posted by Microsoft on 4/19/2010 at 11:42 PM
Thanks for your feedback. We were able to reproduce the issue you are seeing. We are routing this issue to the appropriate group within the Visual Studio Product Team for triage and resolution. These specialized experts will follow-up with your issue.
Sign in to post a workaround.
File Name Submitted By Submitted On File Size  
private.cpp 4/19/2010 1 KB
private.cpp 4/19/2010 1 KB