https://gcc.gnu.org/bugzilla/show_bug.cgi?id=18487
David Malcolm <dmalcolm at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|RESOLVED |UNCONFIRMED CC| |dmalcolm at gcc dot gnu.org Resolution|WONTFIX |--- Ever confirmed|1 |0 --- Comment #9 from David Malcolm <dmalcolm at gcc dot gnu.org> --- (In reply to Andrew Pinski from comment #8) > I don't think I agree with closing this as won't fix as shown now we have > three duplicated bugs asking the same thing. I agree; reopening. It may not be possible to implement a perfect test for this, but it seems to me that it's possible to implement a warning that catches a subset of cases without false positives (at the cost of having false negatives). As a first iteration of an implementation: for all fns labelled as pure/const: for all basic blocks that are guaranteed to be in a path through the function: for all stmts in BB: if stmt is non-pure/non-const: issue a warning (yes, this would miss some things e.g. if (COND) non-pure else non-pure but could be cheap and effective)