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: [PING^2] ada: Add limitations on the acceptable prefixes of 'Old


On  7/05, Robert Dewar wrote:

>> Item 2 ('Old of an "out" mode parameter) makes zero sense and is likely
>> to be a programming error. "out" parameters can be read since
>> Ada 95 but doing so before writing them is bogus. Do you have a problem with
>> this one?
>
> It might be better to have a warning here, than burden 'Old with a
> bunch of rather arbitrary legality rules.

I fail to see why a warning is better than an error here, as the
compiler is 100% sure that it cannot be correct.

Legality rules preventing "out" parameters to be read before they are
initialized do not exist because some cases would be undecidable. So
reading "out" parameters is legal, and the compiler cannot do anything
but warn about it even if it knows it is incorrect in some cases. But
here, taking 'Old on an "out" parameter always refers to an uninitialized
variable and can never be correct. This is why I think it deserves a
legality rule, as simple as "'Old cannot be applied to OUT mode
parameters".

> Yes, and yes ... functional abstraction is important everywhere, there
> are very nice examples of using function calls for 'Old, for example
> one interesting post condition you can write e.g. for a sort is
>
>    pragma Postcondition (Clock - Clock'Old <= N * log(N) * const);

Ok, I buy it.

>> Item 4 ('Old used in a formal default expression) looks just plain bogus
>> to me. Who would want to write this kind of code and what should it do?
>
> Again I think a warning might be better adding a bunch of legality
> rules. It is also useless to multiply by 1, but we don't consider a
> rule making this illegal (probably multiplying by 1 should give a
> warning, though it doesn't right now :-))

Are there other cases where the place of a function call can change its
legality? In the item 4 of
   http://gcc.gnu.org/ml/gcc-patches/2008-04/msg00978.html
I give an example where a function using 'Old in a formal default
expression cannot be called from a library level declaration.

A legality rule saying "'Old cannot be used in the default expression of
a formal parameter" seems preferable to me than "If 'Old is used in the
default expression of a function formal parameter, this function can
only be called from within a subprogram". One of them is missing here,
and I prefer the first.


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