This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH 08/16] libiberty.h: Provide a CLEAR_VAR macro


> +/* Fill an lvalue with zero bits.  */
> +#define CLEAR_VAR(S) \
> +  do { memset (&(S), 0, sizeof (S)); } while (0)

Hmmm... I don't see the point in this.  The macro is almost as long as
a bare memset() would be, and replaces a well-known function with
something unknown outside this project.  It neither hides a bug in an
OS nor provides a common way to handle a difficult task across
platforms.

You also do NOT want to use memset to zero out a C++ structure that
contains more than just "plain old data" - you could easily corrupt
the structure's hidden data.

Also, pedantically speaking, "all bits zero" is not guaranteed to be
the same as float 0.0, double 0.0, or pointer (void *)0.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]