MSVC 2017.5 deprecation warnings

239 views
Skip to first unread message

Neil Hodgson

unread,
Dec 6, 2017, 5:46:22 PM12/6/17
to Scintilla mailing list
Just updated to the new (.5) release of Visual C++ 2017 (also called 15.5.0). There are new deprecation warnings due to derivation of regex support classes from std::iterator. While this produces many warnings, the core issue is a C++17 deprecation:

C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.12.25827\include\xutility(620): warning C4996: 'std::iterator<std::bidirectional_iterator_tag,wchar_t,ptrdiff_t,_Ty *,_Ty &>::iterator_category': 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.

Could someone on Windows interested in regex look into this and work out a patch, please?

Neil

George Hummet

unread,
Dec 7, 2017, 9:51:58 AM12/7/17
to scintilla-interest

   Could someone on Windows interested in regex look into this and work out a patch, please?

   Neil

Hey Neal, im not quite what you might call an expert in regexps but i will see what i can do.
enjoy, Thorsten

George Hummet

unread,
Dec 8, 2017, 10:28:21 AM12/8/17
to scintilla-interest
had a quick look,dont think its worth the effort, sorry.
Message has been deleted
Message has been deleted
Message has been deleted

Greg Smith

unread,
Dec 11, 2017, 1:07:17 PM12/11/17
to scintilla-interest
The fix is to remove use of the iterator and provide the 5 typedefs:

class ByteIterator : public std::iterator<std::bidirectional_iterator_tag, char> {
public:
 
const Document *doc;


 becomes:
class ByteIterator {
public:
       
typedef std::bidirectional_iterator_tag iterator_category;
       
typedef char value_type;
       
typedef ptrdiff_t difference_type;
       
typedef char* pointer;
       
typedef char& reference;
 
const Document *doc;

And similarly for the other two cases with char replaced by wchar_t.

There never has been a requirement for iterators to derive from std::iterator, and this can be the source of perplexing parse errors due to two stage name lookup (especially as the Microsoft compiler used to get this wrong by allowing you to refer to dependent names declared in a base class).
 

Neil Hodgson

unread,
Dec 12, 2017, 3:51:10 PM12/12/17
to scintilla...@googlegroups.com
Greg Smith:

> The fix is to remove use of the iterator and provide the 5 typedefs:
>
> class ByteIterator : public std::iterator<std::bidirectional_iterator_tag, char> {
> public:
> const Document *doc;
>
>
> becomes:
> class ByteIterator {
> public:
> typedef std::bidirectional_iterator_tag iterator_category;
> typedef char value_type;
> typedef ptrdiff_t difference_type;
> typedef char* pointer;
> typedef char& reference;
> const Document *doc;
>
> And similarly for the other two cases with char replaced by wchar_t.

OK, committed:
https://sourceforge.net/p/scintilla/code/ci/fd2f856b8d582df2e3e60073721a84b9f464a72b/

Neil

Reply all
Reply to author
Forward
0 new messages