This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: Uninitialized tree node
- To: egcs-patches at cygnus dot com
- Subject: Re: Uninitialized tree node
- From: Graham <grahams at rcp dot co dot uk>
- Date: Wed, 25 Nov 1998 13:30:39 +0000
- References: <vyzvhk414nn.fsf@issan.cs.uni-dortmund.de>
- Reply-To: grahams at rcp dot co dot uk
Hi
There's at least two other instances of similar code in gcc/cp/lex.c
which probably may suffer from the same problem.
By coincedence I have some similar patches for gcc/rtl.c and gcc/tree.c
I haven't submitted them yet because I'm undecided between two
alternative
approches.
A) Replace initialisation/copy loops with calls to bzero() and bcopy()
respectively. The only downside with this is it will hit compilation
speed,
but will probably only get noticed on the older hardware.
B) Introduce two macros QBZERO() and QBCOPY() which are analogs
of bzero() and bcopy() and are based on the existing code initialisation
code which is `duplicated' several times, but doesn't always handle the
case
where the size isn't a multiple of sizeof(int).
Here are my definitions of QBZERO and QBCOPY
#define QBZERO(PTR, COUNT) \
do { \
register int i; \
/* Clear a word at a time. */ \
for (i = ((COUNT) / sizeof (int)) - 1; i >= 0; i--) \
((int *)(PTR))[i] = 0; \
/* Clear any extra bytes. */ \
for (i = (COUNT) / sizeof (int) * sizeof (int); i < (COUNT); i++) \
((char *)(PTR))[i] = 0; \
} while (0)
#define QBCOPY(SRC,DEST,COUNT) \
do { \
register int i; \
/* Copy a word at a time. */ \
for (i = ((COUNT) / sizeof (int)) - 1; i >= 0; i--) \
((int *)(DEST))[i] = ((int *)(SRC))[i]; \
/* Copy any extra bytes. */ \
for (i = (COUNT) / sizeof (int) * sizeof (int); i < (COUNT); i++) \
((char *)(DEST))[i] = ((char *)(SRC))[i]; \
} while (0)
Does anyone have any preferences on which way to go.
I'm inclinded to go with option A
Graham