[LLVMdev] totally lost
Juan Nicolas Ruiz
juanruiz at students.uiuc.edu
Fri Nov 1 17:03:01 PST 2002
shouldn't the malloc() be something like malloc(sizeof(int)*size)?
You're allocating 5 bytes, which is probably not the size of an int in
llvm (it's definitely not the size of an int in sparc), and later
you're trying to access c[1], which starts at byte 4 but is out of
bounds.
On Fri, 1 Nov 2002, Xiaodong Li wrote:
> Dear LLVM:
>
> I wrote a small testcase and I can compiler and run it with gcc, But with
> llvm, I got weird error like the following. I really don't know what's
> going on. Could you explain? Thanks a lot -Jerry
>
> Error Message:
> xli3|csil-suna38|~/mp2|[25]% llvmgcc testcase3.c
> testcase3.c: In function `init':
> testcase3.c:5: warning: cast to pointer from integer of different size
> /usr/dcs/projects/cs426/Software/gcc_install/bin/../lib/gcc-lib/llvm/3.1/as:
> /var/tmp//cc7nkKdc.s:428: Redefinition of value named 'reg213' in the 'int
> *' type plane!
>
> My code:
> /* --------------------testcase -----------------------*/
> #include <stdio.h>
> int *init(int size)
> {
> int *a = (int *)malloc(size);
> return a;
> }
> int main()
> {
> int *c;
> c = init(5);
> printf("c[1]=%d\n", c[1]);
> free( c );
> return;
> }
>
>
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu
> http://mail.cs.uiuc.edu/mailman/listinfo/llvmdev
>
Juan Nicolas Ruiz | Dept. of Computer Science
Quidquid latine dictum sit, altum viditur. | Univ. of Illinois
(Whatever is said in Latin sounds profound)| #213 CSL, +1-217-244-1134
More information about the llvm-dev
mailing list