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 -
Replying to @RichFelker @oshepherd
yes an LLVM bug is filed about the case where you make a pointer (on a 32-bit machine) and try to guess it in a loop and it thinks you can't
1 reply 0 retweets 0 likes -
Replying to @johnregehr @oshepherd
If your guess involves any accesses, I think the bug is invalid; the compiler can infer UB from the access.
2 replies 0 retweets 0 likes
But if you just try guessing by comparing for equality, esp after casting to uintptr_t, I think assuming no match is a clear bug.
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.