[LLVMdev] mismatched function signatures

Jianzhou Zhao jianzhou at seas.upenn.edu
Thu Jul 21 06:46:13 PDT 2011

On Thu, Jul 21, 2011 at 4:29 AM, Anton Korobeynikov
<anton at korobeynikov.info> wrote:
>> It seems fine if the mismatched types are the types that can work with
>> trunc or ext. But other types, for example, structs, may not work. In
>> general, if a parameter is of type t1, and its argument is of type t2,
>> what value of the argument can we expect? Will it be a random value of
>> type t2?
> The call to function with mismatched signature yields undefined
> behavior. So, everything can happen. E.g. you can expect that the
> binary will format your hard drive and steal your cookies :)

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?

> --
> With best regards, Anton Korobeynikov
> Faculty of Mathematics and Mechanics, Saint Petersburg State University


More information about the llvm-dev mailing list