In the following code, there is a subtle bug because the first entry of the array is missing a comma, so the string literals get implicitly concatenated together.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
#include <iostream>
#include <array>
int main()
{
constchar* exts[] = {
"*.exe""*.msi",
"*.dll"
};
for (std::size_t i = 0; i < std::size(exts); i++)
{
std::cout << exts[i] << '\n';
}
}
*.exe*.msi
*.dll
Does anyone know of a way to force GCC or another popular compiler to warn here? If not, does anyone know of an existing code analysis tool that can warn here? Or do I have to write my own tool to do it?