RESOLVED FIXED 236014
[JSC] Remove compiler warning in TrailingArray.h
https://bugs.webkit.org/show_bug.cgi?id=236014
Summary [JSC] Remove compiler warning in TrailingArray.h
Xan Lopez
Reported 2022-02-02 06:42:36 PST
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)) { \
Attachments
v1 (1.73 KB, patch)
2022-02-02 06:44 PST, Xan Lopez
ysuzuki: review+
v2 (1.82 KB, patch)
2022-02-02 11:29 PST, Xan Lopez
no flags
Xan Lopez
Comment 1 2022-02-02 06:44:51 PST
Created attachment 450642 [details] v1 Remove compiler warning.
Yusuke Suzuki
Comment 2 2022-02-02 11:04:04 PST
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.
Xan Lopez
Comment 3 2022-02-02 11:29:04 PST
Created attachment 450678 [details] v2 Fix compiler warning with static_cast
EWS
Comment 4 2022-02-02 13:39:15 PST
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].
Radar WebKit Bug Importer
Comment 5 2022-02-02 13:40:17 PST
Note You need to log in before you can comment on or make changes to this bug.