On Thu, 3 Jul 2008, Diego Novillo wrote: > Kaveh, > > I'm testing trunk as of revision 137346 with > --enable-gather-detailed-memory-stats and I'm getting a bootstrap > failure due to C++ cast problems. Since you've been hacking at this > and added the stricter checking, could you fix the invalid casts? If > not, I may try to produce a patch soonish. > Thanks. Diego.
Actually it's --enable-gather-detailed-mem-stats ("mem" not "memory"), this threw me for a while as I was unable to reproduce any failures until I figured that out. :-) Patch completed bootstrapped on x86_64-unknown-linux-gnu configured with --enable-gather-detailed-mem-stats. Okay for mainline? --Kaveh 2008-07-03 Kaveh R. Ghazi <[EMAIL PROTECTED]> * alloc-pool.c (hash_descriptor, eq_descriptor, alloc_pool_descriptor): Fix -Wc++-compat warnings. * bitmap.c (hash_descriptor, eq_descriptor, bitmap_descriptor): Likewise. * ggc-common.c (hash_descriptor, eq_descriptor, hash_ptr, eq_ptr, loc_descriptor, ggc_prune_ptr, ggc_free_overhead, final_cmp_statistic, cmp_statistic, dump_ggc_loc_statistics): Likewise. * varray.c (hash_descriptor, eq_descriptor, varray_descriptor): Likewise. diff -rup orig/egcc-SVN20080703/gcc/alloc-pool.c egcc-SVN20080703/gcc/alloc-pool.c --- orig/egcc-SVN20080703/gcc/alloc-pool.c 2008-06-29 07:37:45.000000000 +0200 +++ egcc-SVN20080703/gcc/alloc-pool.c 2008-07-03 19:18:54.000000000 +0200 @@ -81,13 +81,15 @@ static htab_t alloc_pool_hash; static hashval_t hash_descriptor (const void *p) { - const struct alloc_pool_descriptor *d = p; + const struct alloc_pool_descriptor *const d = + (const struct alloc_pool_descriptor * )p; return htab_hash_pointer (d->name); } static int eq_descriptor (const void *p1, const void *p2) { - const struct alloc_pool_descriptor *d = p1; + const struct alloc_pool_descriptor *const d = + (const struct alloc_pool_descriptor *) p1; return d->name == p2; } @@ -106,7 +108,7 @@ alloc_pool_descriptor (const char *name) 1); if (*slot) return *slot; - *slot = xcalloc (sizeof (**slot), 1); + *slot = XCNEW (struct alloc_pool_descriptor); (*slot)->name = name; return *slot; } diff -rup orig/egcc-SVN20080703/gcc/bitmap.c egcc-SVN20080703/gcc/bitmap.c --- orig/egcc-SVN20080703/gcc/bitmap.c 2008-07-03 02:00:18.000000000 +0200 +++ egcc-SVN20080703/gcc/bitmap.c 2008-07-03 19:21:22.000000000 +0200 @@ -51,7 +51,8 @@ static htab_t bitmap_desc_hash; static hashval_t hash_descriptor (const void *p) { - const struct bitmap_descriptor *const d = p; + const struct bitmap_descriptor *const d = + (const struct bitmap_descriptor *) p; return htab_hash_pointer (d->file) + d->line; } struct loc @@ -63,8 +64,9 @@ struct loc static int eq_descriptor (const void *p1, const void *p2) { - const struct bitmap_descriptor *const d = p1; - const struct loc *const l = p2; + const struct bitmap_descriptor *const d = + (const struct bitmap_descriptor *) p1; + const struct loc *const l = (const struct loc *) p2; return d->file == l->file && d->function == l->function && d->line == l->line; } @@ -88,7 +90,7 @@ bitmap_descriptor (const char *file, con 1); if (*slot) return *slot; - *slot = xcalloc (sizeof (**slot), 1); + *slot = XCNEW (struct bitmap_descriptor); (*slot)->file = file; (*slot)->function = function; (*slot)->line = line; diff -rup orig/egcc-SVN20080703/gcc/ggc-common.c egcc-SVN20080703/gcc/ggc-common.c --- orig/egcc-SVN20080703/gcc/ggc-common.c 2008-06-26 02:31:32.000000000 +0200 +++ egcc-SVN20080703/gcc/ggc-common.c 2008-07-03 19:28:44.000000000 +0200 @@ -791,7 +791,7 @@ static htab_t loc_hash; static hashval_t hash_descriptor (const void *p) { - const struct loc_descriptor *const d = p; + const struct loc_descriptor *const d = (const struct loc_descriptor *) p; return htab_hash_pointer (d->function) | d->line; } @@ -799,8 +799,8 @@ hash_descriptor (const void *p) static int eq_descriptor (const void *p1, const void *p2) { - const struct loc_descriptor *const d = p1; - const struct loc_descriptor *const d2 = p2; + const struct loc_descriptor *const d = (const struct loc_descriptor *) p1; + const struct loc_descriptor *const d2 = (const struct loc_descriptor *) p2; return (d->file == d2->file && d->line == d2->line && d->function == d2->function); @@ -819,7 +819,7 @@ struct ptr_hash_entry static hashval_t hash_ptr (const void *p) { - const struct ptr_hash_entry *const d = p; + const struct ptr_hash_entry *const d = (const struct ptr_hash_entry *) p; return htab_hash_pointer (d->ptr); } @@ -827,7 +827,7 @@ hash_ptr (const void *p) static int eq_ptr (const void *p1, const void *p2) { - const struct ptr_hash_entry *const p = p1; + const struct ptr_hash_entry *const p = (const struct ptr_hash_entry *) p1; return (p->ptr == p2); } @@ -848,7 +848,7 @@ loc_descriptor (const char *name, int li slot = (struct loc_descriptor **) htab_find_slot (loc_hash, &loc, 1); if (*slot) return *slot; - *slot = xcalloc (sizeof (**slot), 1); + *slot = XCNEW (struct loc_descriptor); (*slot)->file = name; (*slot)->line = line; (*slot)->function = function; @@ -883,7 +883,7 @@ ggc_record_overhead (size_t allocated, s static int ggc_prune_ptr (void **slot, void *b ATTRIBUTE_UNUSED) { - struct ptr_hash_entry *p = *slot; + struct ptr_hash_entry *p = (struct ptr_hash_entry *) *slot; if (!ggc_marked_p (p->ptr)) { p->loc->collected += p->size; @@ -907,7 +907,7 @@ ggc_free_overhead (void *ptr) { PTR *slot = htab_find_slot_with_hash (ptr_hash, ptr, htab_hash_pointer (ptr), NO_INSERT); - struct ptr_hash_entry *p = *slot; + struct ptr_hash_entry *p = (struct ptr_hash_entry *) *slot; p->loc->freed += p->size; htab_clear_slot (ptr_hash, slot); free (p); @@ -917,8 +917,10 @@ ggc_free_overhead (void *ptr) static int final_cmp_statistic (const void *loc1, const void *loc2) { - struct loc_descriptor *l1 = *(struct loc_descriptor **) loc1; - struct loc_descriptor *l2 = *(struct loc_descriptor **) loc2; + const struct loc_descriptor *const l1 = + *(const struct loc_descriptor *const *) loc1; + const struct loc_descriptor *const l2 = + *(const struct loc_descriptor *const *) loc2; long diff; diff = ((long)(l1->allocated + l1->overhead - l1->freed) - (l2->allocated + l2->overhead - l2->freed)); @@ -929,8 +931,10 @@ final_cmp_statistic (const void *loc1, c static int cmp_statistic (const void *loc1, const void *loc2) { - struct loc_descriptor *l1 = *(struct loc_descriptor **) loc1; - struct loc_descriptor *l2 = *(struct loc_descriptor **) loc2; + const struct loc_descriptor *const l1 = + *(const struct loc_descriptor *const *) loc1; + const struct loc_descriptor *const l2 = + *(const struct loc_descriptor *const *) loc2; long diff; diff = ((long)(l1->allocated + l1->overhead - l1->freed - l1->collected) - @@ -967,7 +971,7 @@ dump_ggc_loc_statistics (bool final ATTR ggc_force_collect = true; ggc_collect (); - loc_array = xcalloc (sizeof (*loc_array), loc_hash->n_elements); + loc_array = XCNEWVEC (struct loc_descriptor *, loc_hash->n_elements); fprintf (stderr, "-------------------------------------------------------\n"); fprintf (stderr, "\n%-48s %10s %10s %10s %10s %10s\n", "source location", "Garbage", "Freed", "Leak", "Overhead", "Times"); diff -rup orig/egcc-SVN20080703/gcc/varray.c egcc-SVN20080703/gcc/varray.c --- orig/egcc-SVN20080703/gcc/varray.c 2008-06-20 20:34:53.000000000 +0200 +++ egcc-SVN20080703/gcc/varray.c 2008-07-03 19:30:06.000000000 +0200 @@ -49,13 +49,13 @@ static htab_t varray_hash; static hashval_t hash_descriptor (const void *p) { - const struct varray_descriptor *d = p; + const struct varray_descriptor *d = (const struct varray_descriptor *) p; return htab_hash_pointer (d->name); } static int eq_descriptor (const void *p1, const void *p2) { - const struct varray_descriptor *d = p1; + const struct varray_descriptor *d = (const struct varray_descriptor *) p1; return d->name == p2; } @@ -74,7 +74,7 @@ varray_descriptor (const char *name) 1); if (*slot) return *slot; - *slot = xcalloc (sizeof (**slot), 1); + *slot = XCNEW (struct varray_descriptor); (*slot)->name = name; return *slot; }