gasLimit should be int64_t
mgraczyk opened this issue · comments
Michael Graczyk commented
On this line, gasLimit is compared with ~9 billion, a number larger than the largest int on most/all platforms.
https://github.com/comaeio/porosity/blob/cdca1693857fe99af546e294756c693536731833/porosity/porosity/VMState.cpp#L344
This definition should be int64_t gasLimit = int64_t...
:
https://github.com/comaeio/porosity/blob/cdca1693857fe99af546e294756c693536731833/porosity/porosity/VMState.cpp#L314
Lev Dubinets commented
Also, -Wtautological-constant-out-of-range-compare
causes a warning for this comparison when compiling.
> make
c++ -std=c++14 -c -o BasicBlocks.o BasicBlocks.cpp
c++ -std=c++14 -c -o CommonData.o CommonData.cpp
c++ -std=c++14 -c -o Contract.o Contract.cpp
c++ -std=c++14 -c -o Debug.o Debug.cpp
c++ -std=c++14 -c -o Disassm.o Disassm.cpp
c++ -std=c++14 -c -o Instruction.o Instruction.cpp
c++ -std=c++14 -c -o Output.o Output.cpp
c++ -std=c++14 -c -o Porosity.o Porosity.cpp
c++ -std=c++14 -c -o SHA3.o SHA3.cpp
c++ -std=c++14 -c -o Statement.o Statement.cpp
c++ -std=c++14 -c -o Utils.o Utils.cpp
c++ -std=c++14 -c -o VMState.o VMState.cpp
VMState.cpp:344:26: warning: comparison of constant 9999965936 with expression of type 'int' is always true [-Wtautological-constant-out-of-range-compare]
if (gasLimit != 0x2540B5EF0) exp << ".gas(" << gasLimit << ")";
~~~~~~~~ ^ ~~~~~~~~~~~
1 warning generated.
c++ -std=c++14 BasicBlocks.o CommonData.o Contract.o Debug.o Disassm.o Instruction.o Output.o Porosity.o SHA3.o Statement.o Utils.o VMState.o -o porosity