Bug 212290

Summary: REGRESSION (r204916): WTF::isValidEnum() has a typo in static_assert making it a tautological comparison
Product: WebKit Reporter: David Kilzer (:ddkilzer) <ddkilzer>
Component: Web Template FrameworkAssignee: David Kilzer (:ddkilzer) <ddkilzer>
Status: RESOLVED FIXED    
Severity: Normal CC: achristensen, benjamin, cdumez, cmarcelo, darin, ews-watchlist, webkit-bug-importer, ysuzuki
Priority: P2 Keywords: InRadar
Version: Other   
Hardware: Unspecified   
OS: Unspecified   
Bug Depends on: 161103    
Bug Blocks:    
Attachments:
Description Flags
Patch v1 none

Description David Kilzer (:ddkilzer) 2020-05-22 16:50:53 PDT
WTF::isValidEnum() has a typo in static_assert making it a tautological comparison.

template<typename E, typename T, std::enable_if_t<std::is_enum<E>::value && !std::is_same<std::underlying_type_t<E>, bool>::value && !HasCustomIsValidEnum<E>::value>* = nullptr>
constexpr bool isValidEnum(T t)
{
    static_assert(sizeof(T) >= std::underlying_type_t<E>(), "Integral type must be at least the size of the underlying enum type");

    return EnumValueChecker<T, typename EnumTraits<E>::values>::isValidEnum(t);
}

Note that `sizeof(T) >= std::underlying_type_t<E>()` is a tautological comparison because `std::underlying_type_t<E>()` evaluates to zero.
Comment 1 David Kilzer (:ddkilzer) 2020-05-22 16:54:00 PDT
Created attachment 400089 [details]
Patch v1
Comment 2 David Kilzer (:ddkilzer) 2020-05-22 16:56:09 PDT
Regressed in r204916:  <https://trac.webkit.org/r204916>
Comment 3 Yusuke Suzuki 2020-05-22 17:44:04 PDT
Comment on attachment 400089 [details]
Patch v1

r=me
Comment 4 EWS 2020-05-22 20:31:28 PDT
Committed r262092: <https://trac.webkit.org/changeset/262092>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 400089 [details].
Comment 5 Radar WebKit Bug Importer 2020-05-22 20:32:15 PDT
<rdar://problem/63562556>