here we try to guess the value of a pointer -- LLVM says we cannot guess it and GCC suspects we canhttps://godbolt.org/g/SFLwz4
-
Show this thread
-
anyone know offhand whether C99 or C11 explicitly justifies LLVM's optimization?
8 replies 0 retweets 0 likesShow this thread -
Replying to @johnregehr
malloc is defined to return a pointer which does not alias any pre-existing object
4 replies 0 retweets 1 like -
If nothing else, malloc returns a pointer to memory suitably aligned for any type, and 0xdeadbeef most definitely is not.
4 replies 1 retweet 3 likes -
Replying to @RichFelker @oshepherd
good point but of course neither compiler cares about the actual value...
1 reply 0 retweets 0 likes -
Replying to @johnregehr @oshepherd
Indeed. At first it seems reasonable that a ptr converted from int could only meaningfully point to fixed hw or an obj whose addr leaked...
1 reply 0 retweets 0 likes -
However pigeonhole principle makes things get nasty.
2 replies 0 retweets 0 likes -
Maybe the valid transform is just that LLVM can assume either the int is a hw address that can't overlap with something usable by malloc...
2 replies 0 retweets 0 likes -
Replying to @RichFelker @oshepherd
if you turn off ASLR you can actually guess the address though :)
1 reply 0 retweets 0 likes
A transformation that (effectively, as-if principle) changes the address malloc returns seems perfectly valid.
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.