Re:Tis-interpreter – find subtle bugs in programs written in...
by vrfcodf on Saturday April 09, 2016 @03:43AM
(#11460391)
That is not correct. The type used to write to the memory is int, not void or char. If the object, whose address is passed to the function is not compatible with int, the behavior is undefined.
You should read about strict aliasing, you will be surprised.
Re:Tis-interpreter – find subtle bugs in programs written in...
by PeCaN on Saturday April 09, 2016 @03:48AM
(#11460400)
You're right, I misread and misinterpreted that! Thanks.
Somehow I wasn't thinking and didn't realize that `t` aliases whatever was passed as `p`, and dereferencing a non int or char pointer would be undefined there.
Of course if you pass a pointer to a type smaller than sizeof(int)-1 bytes then it accesses uninitialized memory which is UB, but that's a different issue.
EDIT: Aaaand I wasn't thinking.
̶E̶D̶I̶T̶ ̶E̶D̶I̶T̶:̶ ̶N̶o̶t̶ ̶o̶n̶l̶y̶ ̶d̶i̶d̶ ̶I̶ ̶m̶i̶s̶-̶r̶e̶a̶d̶,̶ ̶b̶u̶t̶ ̶v̶o̶i̶d̶ ̶p̶o̶i̶n̶t̶e̶r̶ ̶c̶a̶n̶'̶t̶ ̶a̶l̶i̶a̶s̶ ̶a̶n̶y̶t̶h̶i̶n̶g̶ ̶i̶n̶ ̶s̶t̶a̶n̶d̶a̶r̶d̶ ̶C̶ ̶a̶n̶y̶w̶a̶y̶ ̶(̶t̶h̶o̶u̶g̶h̶ ̶I̶I̶R̶C̶ ̶G̶C̶C̶ ̶t̶r̶e̶a̶t̶s̶ ̶i̶t̶ ̶l̶i̶k̶e̶ ̶c̶h̶a̶r̶ ̶p̶o̶i̶n̶t̶e̶r̶ ̶w̶r̶t̶ ̶a̶l̶i̶a̶s̶i̶n̶g̶)̶.
EDIT EDIT EDIT: Actually maybe it can and I shouldn't be reading technical docs at 2am.