I'm learning now C++ I'm reading the book Effective C++ (Scott Meyers). In the book, there is an item about const variables, and I try to work with them. I notice something very interesting that I what to know if it bug in C++: (I'm working with C++98 standard)
void Test(const int i)
{
int arr[i] = {0};
for (int j = 0; i > j; ++j)
{
arr[j] = i;
}
}
This function will compile and work exactly as I want (create int array on the stack with the size of 'i'. When I remove the 'const' from 'i' it won't compile. I try this on gcc and clang.
Edit: link to Compiler Explorer