PATCH: Tree checking failure in C++

Mark Mitchell
Tue Oct 24 08:21:00 GMT 2000

>>>>> "Richard" == Richard Kenner <> 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

(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

I know it's a coarse measure, but:

  bash$ find . -name '*.c' -o -name '*.h' | 
      xargs -n10 grep 'CODE.*==.*ERROR_MARK' | wc -l
  bash$ find . -name '*.c' -o -name '*.h' | 
      xargs -n10 grep '==.*error_mark_node' | wc -l

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.


Mark Mitchell         
CodeSourcery, LLC     

More information about the Gcc-patches mailing list