STL4015 warning when compiling with jsapi.h in VS2017 /std:c++17
Categories
(Core :: JavaScript Engine, defect, P3)
Tracking
()
Tracking | Status | |
---|---|---|
firefox68 | --- | fixed |
People
(Reporter: qwertiest, Assigned: qwertiest)
References
Details
Attachments
(1 file)
1.45 KB,
patch
|
Waldo
:
review+
|
Details | Diff | Splinter Review |
User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:65.0) Gecko/20100101 Firefox/65.0
Steps to reproduce:
- Include jsapi.h header in .cpp of your choice.
- Compile .cpp with Visual Studio 2017 /std:c++17 /W3
Problematic line is present in the trunk as well: https://dxr.mozilla.org/mozilla-central/source/js/public/ErrorReport.h?q=JSErrorNotes&redirect_type=direct#179
Solution:
- Remove inheritance from std::iterator<std::input_iterator_tag, js::UniquePtr<Note>>.
- Add the following lines in class definition:
using iterator_category = std::input_iterator_tag;
using value_type = js::UniquePtr<Note>;
using difference_type = ptrdiff_t;
using pointer = value_type*;
using reference = value_type&;
Note: it also appears in several non-SM headers: https://dxr.mozilla.org/mozilla-central/search?q=public+std%3A%3Aiterator
Actual results:
warning C4996: 'std::iterator<std::input_iterator_tag,mozilla::UniquePtr<JSErrorNotes::Note,JS::DeletePolicy<T>>,ptrdiff_t,_Ty *,_Ty &>::reference': warning STL4015: The std::iterator class template (used as a base class to provide typedefs) is deprecated in C++17. (The <iterator> header is NOT deprecated.) The C++ Standard has never required user-defined iterators to derive from std::iterator. To fix this warning, stop deriving from std::iterator and start providing publicly accessible typedefs named iterator_category, value_type, difference_type, pointer, and reference. Note that value_type is required to be non-const, even for constant iterators. You can define _SILENCE_CXX17_ITERATOR_BASE_CLASS_DEPRECATION_WARNING or _SILENCE_ALL_CXX17_DEPRECATION_WARNINGS to acknowledge that you have received this warning.
Updated•5 years ago
|
Assignee | ||
Comment 1•5 years ago
|
||
Comment 2•5 years ago
|
||
Comment on attachment 9042947 [details] [diff] [review] bug1526245-iterator-traits.patch Review of attachment 9042947 [details] [diff] [review]: ----------------------------------------------------------------- Thanks for this, sorry for the delay!
Assignee | ||
Updated•5 years ago
|
Updated•5 years ago
|
Pushed by cbrindusan@mozilla.com:
https://hg.mozilla.org/integration/mozilla-inbound/rev/b9a53cec8555
Replaced std::iterator inheritance with iterator traits definitions in JSErrorNotes (as required by C++17). r=Waldo
Comment 4•5 years ago
|
||
bugherder |
Description
•