This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]