[Webkit-unassigned] [Bug 186536] New: WTF's internal std::optional implementation should abort() on bad optional access

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Mon Jun 11 12:38:37 PDT 2018


https://bugs.webkit.org/show_bug.cgi?id=186536

            Bug ID: 186536
           Summary: WTF's internal std::optional implementation should
                    abort() on bad optional access
           Product: WebKit
           Version: WebKit Nightly Build
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: Normal
          Priority: P2
         Component: Web Template Framework
          Assignee: webkit-unassigned at lists.webkit.org
          Reporter: mcatanzaro at igalia.com
                CC: utatane.tea at gmail.com

Currently GTK/WPE when built with GCC 7 and higher are suffering from issues like bug #186535 and bug #186189. It's impossible for Apple developers to notice the problems because Apple is still using WTF's internal std::optional, which allows accessing the value of std::optional when it is unset (std::nullopt), which is illegal and causes the program to abort using the standard std::optional.

i.e., we need to fix these FIXMEs in wtf/Optional.h:


  OPTIONAL_MUTABLE_CONSTEXPR T& operator *() & {
    // FIXME: We need to offer special assert function that can be used under the contexpr context.
    // CONSTEXPR_ASSERT(initialized());
    return contained_val();
  }

  OPTIONAL_MUTABLE_CONSTEXPR T&& operator *() && {
    // FIXME: We need to offer special assert function that can be used under the contexpr context.
    // CONSTEXPR_ASSERT(initialized());
    return detail_::constexpr_move(contained_val());
  }

  constexpr T const& value() const& {
    // FIXME: We need to offer special assert function that can be used under the contexpr context.
    // return initialized() ? contained_val() : (throw bad_optional_access("bad optional access"), contained_val());
    return contained_val();
  }

  OPTIONAL_MUTABLE_CONSTEXPR T& value() & {
    // FIXME: We need to offer special assert function that can be used under the contexpr context.
    // return initialized() ? contained_val() : (throw bad_optional_access("bad optional access"), contained_val());
    return contained_val();
  }

  OPTIONAL_MUTABLE_CONSTEXPR T&& value() && {
    // FIXME: We need to offer special assert function that can be used under the contexpr context.
    // if (!initialized()) __THROW_EXCEPTION(bad_optional_access("bad optional access"));
    return std::move(contained_val());
  }

  constexpr T& value() const {
    // FIXME: We need to offer special assert function that can be used under the contexpr context.
    // return ref ? *ref : (throw bad_optional_access("bad optional access"), *ref);
    return *ref;
  }

-- 
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-unassigned/attachments/20180611/11b44080/attachment-0001.html>


More information about the webkit-unassigned mailing list