I found interesting problem, and can't find the proper answer: The error c2148 happens, when you try to create array with 2^31 + 1 elements. Same errors I found in another compilers: Clang, GCC, etc. (Tried on https://godbolt.org/).
Here code example:
#include <iostream>
#include <memory>
using namespace std;
class Boo
{
public:
double* GetArr() {return arr;}
const double* GetArr() const {return arr;}
double arr[100000 * 100000];
private:
};
int main()
{
shared_ptr<Boo> b = make_shared<Boo>();
for (size_t i = 0; i < 100 * 100; ++i)
{
b->arr[i] = i;
cout << i << endl;
}
return 0;
}
In this case, I found several compilers(clang until 10.0), that can compile, but when you run program - you get SIGABORT. So, the question is - that problem is depend on architecture of CPU - and we have limits on assembly level? Or there something else?