[LLVMbugs] [Bug 10509] New: Maps of pairs can trigger horrid overload fallout in __map_value_compare

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Wed Jul 27 01:43:52 PDT 2011


http://llvm.org/bugs/show_bug.cgi?id=10509

           Summary: Maps of pairs can trigger horrid overload fallout in
                    __map_value_compare
           Product: libc++
           Version: unspecified
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: All Bugs
        AssignedTo: hhinnant at apple.com
        ReportedBy: scshunt at csclub.uwaterloo.ca
                CC: llvmbugs at cs.uiuc.edu


The overloaded operator() in __map_value_compare cannot properly accommodate
with _Key is a specialization of pair, as _P and _CP are, and the result is
that the _Key-based overloads will interact in the same overload resolution
with non-_Key based overloads.

Testcase:

#include <map>
#include <utility>

using namespace std;

class Private {
  Private(int);
};

void foo () {
  map<pair<int, int>, Private> Map;
  pair<int, int> Pair;
  Map.find(Pair);
}

Run in C++03 mode, where access control is not subject to SFINAE this causes an
inexplicable access control failure on Private's constructor.

This is because operator()(const pair<int, int>&, const pair<const pair<int,
int>, Private>&), the desired constructor, is participating in the overload
resolution with operator()(const pair<const pair<int, int>, Private>&, const
pair<const pair<int, int>, Private>&), and so a conversion from Private to int
is attempted, causing the access control failure.

-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.



More information about the llvm-bugs mailing list