PATCH: Tree checking failure in C++
Mark Mitchell
mark@codesourcery.com
Tue Oct 24 08:21:00 GMT 2000
>>>>> "Richard" == Richard Kenner <kenner@vlsi1.ultra.nyu.edu> writes:
Richard> + /* Don't crash if the comparison was erroneous. */ +
Richard> if (TREE_CODE (arg0) == ERROR_MARK || TREE_CODE (arg1) ==
Richard> ERROR_MARK) + return const0_rtx;
Richard> Sometimes the test is done this way, but sometimes it's
Richard> done as a comparison with error_mark_node. We should
Richard> standardize on one of them. My vote is for this one
Richard> since I think it's clearer.
Actually, I think there's a pretty clear existing preference for using
`error_mark_node'.
(The last time we had a debate like this, where there was no clear
answer, I promised the SC to make a decision by looking at existing
practice.)
I know it's a coarse measure, but:
bash$ find . -name '*.c' -o -name '*.h' |
xargs -n10 grep 'CODE.*==.*ERROR_MARK' | wc -l
303
bash$ find . -name '*.c' -o -name '*.h' |
xargs -n10 grep '==.*error_mark_node' | wc -l
554
And, of the ERROR_MARK cases, most are in the chill directory.
Finally, the `error_mark_node' test is perhaps better in two ways:
- It's probably faster, since it doesn't involve any data access.
- It reminds us that there is supposed to be only one node with
ERROR_MARK set, ever.
- Finally, since ERROR_MARK tends to be zero, lots of random
storage ends up looking like an ERROR_MARK, which can mask
real errors. Using error_mark_node makes it easier to find
those errors.
So, let's use the `error_mark_node' form instead.
With that change, the patch is fine.
Thanks,
--
Mark Mitchell mark@codesourcery.com
CodeSourcery, LLC http://www.codesourcery.com
More information about the Gcc-patches
mailing list