On Mon, Feb 14, 2022 at 1:54 PM Roger Sayle <ro...@nextmovesoftware.com> wrote: > > > > This simple fix to the middle-end, resolves PR c/104506, by adding an > > explicit check for error_mark_node to useless_type_conversion_p. I first > > trying fixing this in the C front-end, but the type is valid at the point > > that the NOP_EXPR is created, so the poisoned type leaks to the middle-end.
Hmm, IMHO "fixing" something to error_mark after it has possibly be used looks broken. I don't like trying to paper over this in useless_type_conversion_p, the predicate should not be called on an error_mark_node type. Alternatively we might want to create an error_type_node that is at least a type (with main variant error_type_node and TREE_CODE ERROR_TYPE, etc.). But likely more complicated than avoiding to mess with the type of 'x' after the fact? Richard. > > Returning either true or false from useless_type_conversion_p avoids the > > ICE-after-error. Apologies to Andrew Pinski, I hadn't noticed that he'd > > assigned this PR to himself until after my regression testing had finished. > > > > This patch has been tested on x86_64-pc-linux-gnu with make bootstrap and > > make -k check with no new failures. Ok for mainline? > > > > > > 2022-02-14 Roger Sayle <ro...@nextmovesoftware.com> > > > > gcc/ChangeLog > > PR c/104506 > > * gimple-expr.cc (useless_type_conversion_p): Add a check for > > error_mark_node. > > > > gcc/testsuite/ChangeLog > > PR c/104506 > > * gcc.dg/pr104506.c: New test case. > > > > > > Roger > > -- > > >