Hi,

I was trying to figure out how come a memory allocation was short.
I think I've stumbled onto the issue.  "evt_t" is a 48 byte structure
and "tpd_uptr" is a uintptr_t.  "sz" initializes to 52 (decimal).
The value would be correct if I were not trying to multiply the
size of the pointer by 4.  The result should be 64.

Below is a fragment of a GDB session:

79          size_t     sz = sizeof (evt_t) + (4 * sizeof (tpd_uptr));
(gdb) n
85          if (sv_name == NULL) sv_name = (char *)null_z;
(gdb) p sizeof(evt_t)
$15 = 48
(gdb) p (4 * sizeof (tpd_uptr))
$16 = 16
(gdb) p (sizeof (evt_t) + (4 * sizeof (tpd_uptr)))
$17 = 64
(gdb) p sz
$18 = 52
(gdb) set sz = 64
(gdb) p sz
$19 = 64

Here is the compiler information:

$ /usr/bin/gcc --version
gcc (GCC) 4.1.2 20061115 (prerelease) (Debian 4.1.1-21)
Copyright (C) 2006 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

The code was compiled -O0.  Yes, I know the compiler is old.
It is required for the work I am doing.  Oh, if it makes a difference:

static inline void
do_emit_snap_comments_set_event(
    char const * sv_name,  tpd_u32 sv_id,         tpd_u32 vv_id,
    char const * comments)
{
    size_t     sz = sizeof (evt_t) + (4 * sizeof (tpd_uptr));
    evt_t    * evt;

I did look into http://gcc.gnu.org/bugzilla but nothing jumped out.
Thanks for any suggestions!

Regards, Bruce

Reply via email to