CppCoreChecker C-Style warning when using a range based on a vector outline

Assume the following code:

#include <iostream> #include <vector> #include <string> int main() { std::vector<std::string> lines; lines.push_back("line"); for (const auto& s : lines) { std::cout << s; } } 

The following warning appears in the for loop line:

C26493 Do not use C-style casts that will execute static_cast downcast, const_cast, or reinterpret_cast.

Can someone explain where this comes from? Im using Visual Studio 2017 Community Edition version 15.2.

+7
c ++ c ++ 11 static-analysis cpp-core-guidelines
source share
1 answer

As you can see from this error report , it looks like this only happens for the type std::string when pasted into basic_iostream . This bug has been resolved but not yet released, so for now you just need to wait.

+6
source share

All Articles