[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


           Summary: Maps of pairs can trigger horrid overload fallout in
           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.


#include <map>
#include <utility>

using namespace std;

class Private {

void foo () {
  map<pair<int, int>, Private> Map;
  pair<int, int> 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