Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-28890

Workaround for Visual C++ standard library under /permissive-

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Trivial - P5 Trivial - P5
    • 3.5.7
    • Affects Version/s: None
    • Component/s: Build
    • Labels:
    • Fully Compatible
    • ALL
    • Hide

      This is only reproducible with MS Visual C++ that is not yet released.

      Show
      This is only reproducible with MS Visual C++ that is not yet released.

      Visual C++ compiler team is improving conformance of conditional operator for the upcoming VS2017 Update 1 release (15.3). The improvements will be available under a switch, but they will also be implied by the /permissive- switch. Our QA team currently builds regularly MongoDB as a part of RWC suite and so far MongoDB been clean under /permissive-. There is one place right now that will fail to compile under upcoming /Zc:ternary:

      mongo\src\mongo\util\lru_cache.h(134)

      const_iterator cfind(const K& key) const

      { auto it = this->_map.find(key); return (it == this->_map.end()) ? this->end() : it->second; // << Line 134 }

      The problem is not so much in the code itself as other compilers are able to compile it without problems, but in our STL implementation that currently uses inheritance between mutable and const iterators. Stephan acknowledged the library team is planning to get rid of this trick and replace it with conformant implementation in the next major breaking release, but it's not going to happen anytime soon, while as is the above statement is ambiguous (according to the standard; note other compilers would have complained as well should they've been using our STL implementation).

      We would like to ask you guys to patch the above code with an explicit cast to resolve the ambiguity caused by our current iterator implementation as following (pull request is following):

      const_iterator cfind(const K& key) const

      { auto it = this->_map.find(key); return (it == this->_map.end()) ? this->end() : const_iterator(it->second); // << Line 134 }

      This would allow us to keep building MongoDB clean under /permissive- for validating compiler changes.

      Thank you!
      Yuriy

            Assignee:
            adam.martin@mongodb.com ADAM Martin (Inactive)
            Reporter:
            solodon Yuriy Solodkyy
            Votes:
            0 Vote for this issue
            Watchers:
            9 Start watching this issue

              Created:
              Updated:
              Resolved: