jiezhoucs/checkedc-clang

Pass address of stack object to function that takes mmsafe poineters.

Opened this issue · 2 comments

Though it might be not very common, but sometimes a programs takes the address of a stack object and pass it to a function that has already been rewritten to only take mmsafe pointers. Since we've decided to not support mmsafe pointers to stack objects, we need find a way to solve this compatibility issue.

Solution 1: generating multiple versions of a function.

Similar to #7 (comment)
we can make the compiler to generate two (or more) versions of the same function. This may work very well in practice, if such situation is not that common.

Solution 2: stack-to-heap promotion

For all such stack objects, move them from the stack to the heap. This might slow down a program a lot if the stack object allocation is very frequent such as in a big loop.