Hello,
It seems that ConstantFoldCastInstruction in ConstantFold.cpp folds inttoptr instruction with 0 as operand to a null pointer. It makes sense, when talking about a C-style frontend, as the C99 spec (6.3.2.3) states:
“An integer constant expression with the value 0, or such an expression cast to type void *, is called a null pointer constant.”
On the other hand, some architectures use 0 as a valid memory location, and this constant folding seems to be possibly harmful when the code actually tries to access the memory location at address 0.
Is this behavior intentional? Do I miss something? Will a load from address null try to access address 0, or may it become an undef value?
Thanks
Guy