Playing with Pointers is a blog on compilers, JIT internals, LLVM optimizations, and programming language theory.
HN commenters recommend its LuaJIT and LLVM check widening posts, and one points to its constructive Cantor's diagonal argument in Agda.
Thanks, that goes a long way toward an explanation. I'm still a bit surprised though that no compilers seem to complain even if we cast away the const from the properly const-qualified version. Here's the snippet I was playing with that tests all the variations:
https://godbolt.org/g/aaC4B7
I should have expected it, but if you define the "lying" function where the compiler can see the full definition (and don't specify -fno-inline), the loads are optimized out. It made me wonder though whether some variation of this bug might apply : http://www.playingwithpointers.com/ipo-and-derefinement.html
There are many compiler books but no books about JITs in general. There are some good blogpost about LuaJit but not that many. Following Mike Pall (MikeMike on HN or reddit is intressting too)
This is a good start:
http://playingwithpointers.com/archives/1010
Exactly. Here is an implementation of Cantor's diagonal method in Agda which is entirely constructive: http://www.playingwithpointers.com/agda-cantor.html
Is this what you're looking for: http://www.playingwithpointers.com/check-widening-in-llvm.html#final-example ?