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
...or, if it's usable by malloc, that malloc happened not to use it the first time, then the access invoked UB, after which all bets are off
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.