(j3.2006) Some colleagues wish they could count on these working
Malcolm Cohen
malcolm
Tue Sep 10 00:26:28 UTC 2013
>Does anybody not effectively give constants the SAVE attribute?
Yes.
>Does anybody actually kill pointers according to 12.5.2.4p11 if the
>target is a constant or has the SAVE attribute, at least not in "check
>for undefined pointers" mode?
Yes.
Whether the value of a constant expression is materialised at compile time, link
time, or run time, for us depends on the characteristics of the expression. For
example, scalar real/integer/logical are highly likely to be materialised on the
stack, even with no optimisation or checking enabled, and this is likely to end
up with the pointer pointing to random junk later on.
>It would be helpful if literal and named constants effectively had the
>SAVE attribute,
This is more than adequately catered for by using a variable. Variables are
also uniquely determined (one per name) whereas whether different constant
expressions share some or all of their storage is an implementation detail.
> and pointers whose targets ultimately are effective
>arguments with the SAVE attribute do not become undefined as specified
>in 12.5.2.4p11.
Actually pointers are never pointer-associated with something that does not have
the TARGET attribute, though they can be pointer-associated with a TARGET that
is argument-associated with something that does not have the TARGET attribute.
It is impossible to tell the difference in a standard-conforming program, but
obviously different argument-passing technologies will lead to different
behaviours of non-conforming programs - and if you are lucky, an explanatory
error message.
I really do not think you want to give everything the TARGET attribute. Those
who "wish they could count on these working" would seem to be looking at the
world through C-coloured spectacles.
Cheers,
--
................................Malcolm Cohen, Nihon NAG, Tokyo.
More information about the J3
mailing list