[LLVMdev] mismatched function signatures

David Blaikie dblaikie at gmail.com
Thu Jul 21 10:22:40 PDT 2011

> Yes. Then will the undefined behavior, say, formatting hard drive :)
> happen exactly when calling functions with wrong arguments, or be
> delayed until these wrong arguments are used, (for example, when being
> stored into memory)? The similar problem is out-of-bound memory
> access. getelementptr (w/o inbounds flag) can still return an
> out-of-bound location if it is given wrong indexes, and the undefined
> behavior only happens when there are load/store at the location. Did I
> miss any case where any worse situation can happen at call sites?

That's not quite how UB works. UB taints the entire execution - before
or after the actual runtime point at which UB was invoked. Chris
posted a 3 part blog series on the subject starting here:

(for example - going off array bounds could lead the compiler to just
assume the bounds are correct & make certain optimizations, or if it
can prove the bounds are incorrect it could assume that the out of
bounds code was unreachable & not compile it into the product at all
(perhaps from there proving/assuming that some condition must always
be false & removing the condition test too, etc...))

- David

More information about the llvm-dev mailing list