This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug tree-optimization/18487] Warnings for pure and const functions that are not actually pure or const
- From: "dmalcolm at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Thu, 22 Jan 2015 00:44:25 +0000
- Subject: [Bug tree-optimization/18487] Warnings for pure and const functions that are not actually pure or const
- Auto-submitted: auto-generated
- References: <bug-18487-4 at http dot gcc dot gnu dot org/bugzilla/>
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)