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

[Bug target/17180] [3.4 Regression] nearly all g77 tests fail



------- Additional Comments From ebotcazou at gcc dot gnu dot org  2004-09-01 05:10 -------
> i should have always used sizeof(mallocArea_ *). since mallocArea_ and
> mallocArea_* are the same size, this error is not fatal. (i just printed 
> them out on linux/i686/gnu and they are both = 4)
> 
> the code snippet in question, which i think is:
> 
> +  temp = (mallocArea_ *) ptr;
> +  *temp = a; 
> +  ptr = ptr + sizeof(mallocArea_*);
> 
> could be better expressed like this:
> 
>   *(mallocArea_ *)ptr = a;
>   ptr = ptr + sizeof(mallocArea_*)
> 
> *ptr then points to the mallocArea a, after which ptr must be incremented to
> point to the remaining allocated memory.

I don't understand.  The line:

*(mallocArea_ *)ptr = a;

means that you're writing a mallocArea at the address pointed to by ptr.  So you
need to skip that area, which is expressed with:

ptr = ptr + sizeof(mallocArea_);


More generally, the size of the pointer doesn't matter here, only the size of
mallocArea_ is of interest since that's what you write ahead of the chunk of
memory you return.  So I think the correct version is to use sizeof(mallocArea_)
everywhere.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17180

------- You are receiving this mail because: -------
You reported the bug, or are watching the reporter.



Reply to: