This is the mail archive of the gcc@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: C constant expressions proposals


"Joseph S. Myers" <jsm@polyomino.org.uk> writes:

[...]

| > | You should also exclude volatile const variables.
| > 
| > If the model is based on existing semantics in C++, there is no
| > exclusion of const volatile.  I think Mark Mitchell recently applied a
| > patch to the C++ front-end to that effect.
| 
| Isn't that C++ DR 76, incorporated in C++03?  Although the change only 

Yes, you're right.

[...]

| > The reason I mentioned the "constant-valued function" proposal is
| > precisely that it gives a general rule of what users may expect or
| > consider a constant expression.  It needs not  a long list of special
| > functions we would have to update as we go.
| 
| It depends on the body of the function.  We don't have bodies for these 
| built-in functions, but many of them would be much more complicated than 
| just returning a single constant expression, although they could be 
| treated "as if" they return such a constant expression - bearing in mind 

Yes. 

| that some functions are only folded for certain arguments.
| 
| > | when (and we fold some only for particular arguments).  When folding 
| > | arithmetic constant expressions, FENV_ACCESS complicates matters as well 
| > | (i.e. except in static initializers we can't fold, but VLA constraints 
| > | expect us to, and there was a view in the UK C Panel that the problem 
| > | there might be that the expression was still considered constant in the 
| > | presence of FENV_ACCESS rather than in the VLA constraints).  As the 
| > 
| > If FENV_ACCESS is OFF, the compile-time evaluation is permitted.
| > Otherwise, the evaluation is "as-if" done at run time.  Precisely how
| > was the other view derived?
| 
| The expressions are (it seems to be intended) constant expressions by 
| virtue of their operands, and are evaluated as if during execution; F.7.4 
| is explicit on that.  But the constraints in 6.7.5.2#1 expect it to be 
| determinable at translation time whether the constant expression dimension 
| is greater than zero.

I see.

-- Gaby


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