[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#635214: gcc-4.6: [sparc] miscompile PARI/GP 2.5.0 [test-case provided]



On Sat, Jul 23, 2011 at 11:14:34PM +0200, Bill Allombert wrote:
> #include <stdlib.h>
> inline void*
> pari_realloc(void *pointer, size_t size)
> {
>   char *tmp;
>   if (!pointer)
>     tmp = (char *) malloc(size);
>   else
>     tmp = (char *) realloc(pointer,size);

Please fix the obvious problems:
- Never cast the result of malloc.
- realloc can fail.

> inline void **
> stack_base(pari_stack *s) { return (void **) ((char *)s+s->offset); }

Can void ** and pari_stack * alias? I'm not even sure that this is
valid.

> inline void
> stack_init(pari_stack *s, size_t size, void **data)
> {
>   s->offset = (char *)data-(char *)s;

It gets weird.

This whole code does a lot of casting between incompatible pointer
types. I think you have to show that this code is actually valid.

Bastian

-- 
A father doesn't destroy his children.
		-- Lt. Carolyn Palamas, "Who Mourns for Adonais?",
		   stardate 3468.1.



Reply to: