Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-27061

qt or stl-style iterator + implicit sharing = unexpected behavior

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P3: Somewhat important
    • Resolution: Out of scope
    • Affects Version/s: 4.8.2, 5.1.0
    • Fix Version/s: None
    • Component/s: Documentation
    • Labels:
      None
    • Commits:
      499957eb8b1c5150823f05f40f32b04ba13b1640

      Description

      Consider the attached test program.

      A naive user would likely expect the output to be:
      3 2
      1 2
      5
      1 2

      ...as indeed it is when using std::map.

      However, with QMap, the output is:
      3 2
      3 2
      3
      5 2

      I realize this is probably difficult to fix (and the performance cost of doing so might be exorbitant), but it seems like an interesting enough caveat to at least warrant a larger warning in the documentation than the passing remark buried in the container overview page. (Also, the existing warning does not appear to cover that making a copy "invalidates" iterators).

        Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

            • Assignee:
              tmartsum Thorbjørn Lund Martsum
              Reporter:
              matthew.woehlke Matthew Woehlke
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Gerrit Reviews

                There are no open Gerrit changes