[LLVMdev] totally lost

Chris Lattner sabre at nondot.org
Fri Nov 1 17:11:00 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.

It's true that it's not semantically correct code (whatever that means),
but it _should_ compile.  I can reproduce the problem here, so I'll look
into what it will take to fix it.

-Chris

> > 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
>
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://mail.cs.uiuc.edu/mailman/listinfo/llvmdev
>

-Chris

-- 
http://llvm.cs.uiuc.edu/
http://www.nondot.org/~sabre/Projects/




More information about the llvm-dev mailing list