This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: Patch to detect invalid and missing ATTRIBUTE const/pure [take2]
- From: "Joseph S. Myers" <jsm28 at cam dot ac dot uk>
- To: Richard Henderson <rth at redhat dot com>
- Cc: <gcc-patches at gcc dot gnu dot org>
- Date: Mon, 25 Mar 2002 10:34:24 +0000 (GMT)
- Subject: Re: Patch to detect invalid and missing ATTRIBUTE const/pure [take2]
On Mon, 25 Mar 2002, Richard Henderson wrote:
> No. Like I just said, const functions may be called in
> cases that they weren't in the source code.
That sounds like "const" and "pure" attributes are being specified at the
wrong level - in terms of program transformations, rather than in terms of
properties of programs containing calls to such functions.
What are the requirements on programs containing calls to const/pure
functions, so that they should not have undefined behaviour? Is any
requirement at all placed on calls where arguments are invalid? Must a
const function act as const (not change the state of the machine, not
cause undefined behaviour, always return the same result depending only on
the arguments) for all arguments? This would, for example, disallow const
functions that might have signed integer overflow, even if the program
never calls them with arguments that cause overflow.
--
Joseph S. Myers
jsm28@cam.ac.uk