3 ms·
to be clear, in my example the result of oracle() cannot possibly alias with 'x' in C or C++ (and in fact gcc will optimize accordingly). In a different languag
by gpderetta 2y ago
to be clear, in my example the result of oracle() cannot possibly alias with 'x' in C or C++ (and in fact gcc will optimize accordingly). In a different language where addresses are mere integers, things would be more complicated.
- codedokode 2y agoThe result of oracle can point to anything if you write it as return (int *)rand(); Note that rand() returns 32-bit value so you have to call it twice and merge the results to obtain a 64-bit pointer.
- gpderetta 2y agoThe numerical value returned by oracle might physically match the address of the stack slot for 'x', assuming that it exists, but it doesn't mean that, from a language point of view, it is a valid pointer. If forging pointers had defined behaviour, it would be impossible to use the language sanely or perform any kind of optimization.