[Tinycc-devel] When does a CType's ref contain a valid pointer?
From:
David Mertens
Subject:
[Tinycc-devel] When does a CType's ref contain a valid pointer?
Date:
Mon, 27 Jul 2015 11:37:42 -0400
Hello everyone,
While working on symbol table copying, I have run into trouble copying type.ref pointers that point to garbage. Suppose we have a type struct called "type_to_check". Then I thought the following check would ensure that the .ref field was valid:
int btype = type_to_check->type.t & VT_BTYPE; if (btype == VT_PTR || btype == VT_STRUCT || btype == VT_FUNC) {
/* type_to_check.ref is a valid pointer */
}
Yet I seem to run into trouble. Does this look correct?
David
--
"Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are,
by definition, not smart enough to debug it." -- Brian Kernighan