You go to the wonderful world of default promotions in C. Remember, lldb does not know what argument types or return type sin() is. The correct prototype is double sin (double) . When you write
(lldb) p (float) sin(70)
There are two problems with this. First, you provide an integer argument, and the default C promotion rules are going to pass this as an int , 4-byte value for the architectures in question. double , in addition to 8 bytes, is a completely different encoding. This way sin gets garbage input. Secondly, sin() returns double or 8-byte code on these architectures, but you tell lldb to capture 4 bytes and do something meaningful. If you called p (float)sin((double)70) (so that only the return type was wrong), lldb would print a meaningless value, for example 9.40965e + 21 instead of 0.773891.
When you wrote
(lldb) p (double) sin(70.0)
You have fixed these errors. By default, C for a floating-point type should be passed as double . If you called sinf() , you would have problems because the function only expected a float .
If you want to provide lldb with a proper prototype for sin() and not worry about these issues, this is easy. Add this to your ~/.lldbinit file,
settings set target.expr-prefix ~/lldb/prefix.h
(I have a ~/lldb where useful python files are stored, etc.), and ~/lldb/prefix.h will read
extern "C" { int strcmp (const char *, const char *); void printf (const char *, ...); double sin(double); }
(you can see that I also have prototypes for strcmp() and printf() in my prefix file, so I donโt need to drop them.) You donโt want to enter too many things here - this file is added to every expression that you evaluate in lldb and it slows down the evaluation of expressions if you put all the prototypes there in /usr/include .
With this prototype added to my target.expr-prefix parameter:
(lldb) p sin(70) (double) $0 = 0.773890681557889