| Summary: | [JSC] Remove compiler warning in TrailingArray.h | ||||||||
|---|---|---|---|---|---|---|---|---|---|
| Product: | WebKit | Reporter: | Xan Lopez <xan.lopez> | ||||||
| Component: | JavaScriptCore | Assignee: | Nobody <webkit-unassigned> | ||||||
| Status: | RESOLVED FIXED | ||||||||
| Severity: | Normal | CC: | benjamin, cdumez, cmarcelo, ews-watchlist, webkit-bug-importer, xan.lopez, ysuzuki | ||||||
| Priority: | P2 | Keywords: | InRadar | ||||||
| Version: | WebKit Nightly Build | ||||||||
| Hardware: | Unspecified | ||||||||
| OS: | Unspecified | ||||||||
| Attachments: |
|
||||||||
Created attachment 450642 [details]
v1
Remove compiler warning.
Comment on attachment 450642 [details] v1 View in context: https://bugs.webkit.org/attachment.cgi?id=450642&action=review > Source/WTF/wtf/TrailingArray.h:69 > + ASSERT(std::abs(std::distance(first, last)) == size); I think `static_cast<size_t>(std::distance(first, last))` is better. Created attachment 450678 [details]
v2
Fix compiler warning with static_cast
Committed r288993 (246712@main): <https://commits.webkit.org/246712@main> All reviewed patches have been landed. Closing bug and clearing flags on attachment 450678 [details]. |
std::distance returns 'int' here, and we are comparing it with an unsigned int size. I believe we just care about the absolute value in the comparison, so use std::abs. Warning: WTF/Headers/wtf/TrailingArray.h: In instantiation of 'WTF::TrailingArray<Derived, T>::TrailingArray(unsigned int, InputIterator, InputIterator) [with InputIterator = const JSC::RegisterAtOffset*; Derived = WTF::EmbeddedFixedVector<JSC::RegisterAtOffset>; T = JSC::RegisterAtOffset]': WTF/Headers/wtf/EmbeddedFixedVector.h:99:33: required from 'WTF::EmbeddedFixedVector<T>::EmbeddedFixedVector(unsigned int, InputIterator, InputIterator) [with InputIterator = const JSC::RegisterAtOffset*; T = JSC::RegisterAtOffset]' WTF/Headers/wtf/EmbeddedFixedVector.h:52:29: required from 'static WTF::UniqueRef<WTF::EmbeddedFixedVector<T> > WTF::EmbeddedFixedVector<T>::create(InputIterator, InputIterator) [with InputIterator = const JSC::RegisterAtOffset*; T = JSC::RegisterAtOffset]' WTF/Headers/wtf/EmbeddedFixedVector.h:72:22: required from 'WTF::UniqueRef<WTF::EmbeddedFixedVector<T> > WTF::EmbeddedFixedVector<T>::clone() const [with T = JSC::RegisterAtOffset]' WTF/Headers/wtf/FixedVector.h:43:61: required from 'WTF::FixedVector< <template-parameter-1-1> >::FixedVector(const WTF::FixedVector< <template-parameter-1-1> >&) [with T = JSC::RegisterAtOffset]' WTF/Headers/wtf/FixedVector.h:59:21: required from 'WTF::FixedVector< <template-parameter-1-1> >& WTF::FixedVector< <template-parameter-1-1> >::operator=(const WTF::FixedVector< <template-parameter-1-1> >&) [with T = JSC::RegisterAtOffset]' ../../Source/JavaScriptCore/jit/RegisterAtOffsetList.h:37:7: required from here WTF/Headers/wtf/TrailingArray.h:69:43: warning: comparison of integer expressions of different signedness: 'std::iterator_traits<const JSC::RegisterAtOffset*>::difference_type' {aka 'int'} and 'unsigned int' [-Wsign-compare] 69 | ASSERT(std::distance(first, last) == size); WTF/Headers/wtf/Assertions.h:356:11: note: in definition of macro 'ASSERT' 356 | if (!(assertion)) { \