Uploaded image for project: 'Mesos'
  1. Mesos
  2. MESOS-7142

Revisit MSVC decltype bug

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Open
    • Minor
    • Resolution: Unresolved
    • None
    • None
    • None
    • Windows with Visual Studio 2017 RC

    Description

      Review https://reviews.apache.org/r/56781/ works around an existent and acknowledged bug in MSVC. From MSVC team:

      I have preprocessed file from Andy yesterday, thank you. I can verify that this is a bug in the latest compiler where it’s failing to get the right context for the decltype expression for the return type of function. However, MSVC does deduce the right type from the return expression in the body. We have a bug in the compiler logged now and will be tracked for next release.
      We’ll be adding Mesos project to our daily RealWorld Testing set from now on as continuous validation for MSVC compiler. Thank you for bringing this up to our attention.

      template <typename F>
      auto then(F&& f) const-> decltype(this->then(std::forward<F>(f), Prefer()))

      Should really expand to this expression, but it’s failing.

      template <typename F>
      auto then(F&& f) const > decltype(static_cast<const Future<T>*>(this)>then(std::forward<F>(f), Prefer()))

      The workaround from Michael to skip explicit return type for auto function should be actually better source change for MSVC compiler. For completeness sake, you can also just remove ‘this->’ from the decltype expression to make it work for MSVC compiler
      -> decltype(then(std::forward<F>(f), Prefer()))

      Another thing worth pointing out is, adding ‘this->’ in the body of the function shows that MSVC does correctly deduce the return type.
      template <typename F>
      auto then(F&& f) const
      // -> decltype(then(std::forward<F>(f), Prefer()))
      // > decltype(static_cast<const Future<T>*>(this)>then(std::forward<F>(f), Prefer()))

      Unknown macro: { return this->then(std}

      This issue tracks revisiting the work-around when the first patch to VS2017 is released, as the compiler bug itself should be fixed then.

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              andschwa Andrew Schwartzmeyer
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:

                Time Tracking

                  Estimated:
                  Original Estimate - 2h
                  2h
                  Remaining:
                  Remaining Estimate - 2h
                  2h
                  Logged:
                  Time Spent - Not Specified
                  Not Specified