[LLVMdev] c char translated to i8 signext
Jonathan S. Shapiro
shap at eros-os.com
Wed Apr 30 11:06:03 PDT 2008
Not sure if this helps, but...
In the absence of an explicit signed/unsigned qualifier, the ANSI C
standard states that the signedness of char is implementation defined.
In the absence of a prototype, the compiler is obliged to pass that char
as a word, which (if char is signed) requires sign extend.
In the presence of a prototype, the sign extend is probably not strictly
required, but doing it regardless is a partial defense against certain
classes of common programming errors (not sure if this is what is going
So: if you don't have a prototype visible at the call site, add one and
see what happens.
On Wed, 2008-04-30 at 12:55 -0500, Ryan M. Lefever wrote:
> I have a c function that takes a char as a parameter. When it is
> compiled to bytecode, it gets translated to i8 signext. Why is signext
> getting added to the type? It doesn't get added if the parameter is an
> int. Is there a way to alter the parameter in the c code so that it
> simply gets translated to an i8, or is there a way in LLVM to modify the
> parameter's type?
> By the way, I am using LLVM 2.1 in case this has been changed since then.
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu
More information about the llvm-dev