I initialized a full uint256 array like this:

uint256[2**256-1] private test;

And I get this warning for the compiler:

Warning: Variable covers a large part of storage and thus makes collisions likely. Either use mappings or dynamic arrays and allow their size to be increased only in small quantities per transaction.

Can anyone explain to me exactly what this means?

2 Answers 2


The size of the array you are trying to initialize is extremely big (1.1579209e+77 registers of 256 bits each one!!!!). If you do not know the maximum size you will require, just use dynamic arrays or mappings. For instance, with arrays:

uint256[] private test; // array of uints256 of dynamic size

Then you can add values doing:


This will make test = [200, 10] and so on.

Hope this helps.

  • I am well aware what I am doing and there are reason why I want to do it. I want to know what the error means in other words what is the downside of doing this. As far a gas is concerned it is even cheaper then using a dynamic array. Commented May 23, 2018 at 16:09
  • 1
    You are trying to allocate thousands of Terabits for a variable. The compiler is telling you only that this will likely cause data be overwritten, but this will just not work. Using a dynamic array or an array with a reasonable size is the solution. You are talking about the gas but storage is quite expensive in Ethereum and you are trying to initialize a variable with the maximum theoretical size. Good luck.
    – Jaime
    Commented May 23, 2018 at 16:51

I got the answer I was looking for from reddit but I will post it here as well so it my help somebody in the future:

There is "only" 2**256 different storage locations possible. By creating an array that uses almost 2**256 words of storage, it is almost certain that any variable you create would actually conflict with that array. Of course, in reality, the chance of collision is still incredibly low since filling an array of 2**256 words would require more computation than exists in the universe....

A variable like that is deployable on testnet but that is because you can declare "hey this storage should be set aside for the variable 'test'"... but until you actually do something with it, it won't cost any gas. If you tried to iterate through the array, that's when you'd hit out of gas exceptions.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.