ANTLR4 TLexer::Initializer::Initializer() causes debug assert failed

  antlr4, c++

I am generating the C++ parser using MSVC 2017 community edition.
The initializer for the Lexer causes a debug assert.
This Initializer is called before anything else and it is initializing some static objects.
The error dialog shows:
File: minkernelcrtsucrtsrcappcrtheapdebug_heap.cpp
Expression: __acrt_first_block == header
This is all generated code.
I am not sure what is happening.
The code failing is below:

TLexer::Initializer::Initializer() {
  // This code could be in a static initializer lambda, but VS doesn't allow access to private class members from there.
    for (size_t i = 0; i < _symbolicNames.size(); ++i) {
        std::string name = _vocabulary.getLiteralName(i);
        if (name.empty()) {
            name = _vocabulary.getSymbolicName(i); <========= This is failing
        }

        if (name.empty()) {
            _tokenNames.push_back("<INVALID>");
        } else {
      _tokenNames.push_back(name);
    }
    }

Source: Windows Questions C++

LEAVE A COMMENT