Version 1.2 of ais/ai-00320.txt
!standard B.1 (49) 03-02-18 AI95-00320/02
!class binding interpretation 03-01-02
!status work item 03-01-02
!status received 03-01-02
!qualifier Omission
!priority Low
!difficulty Easy
!subject Violating Ada semantics with an interfacing pragma
!summary
The note B.1(49) ("an interfacing pragma might result in an effect
that violates Ada semantics.") is correct.
!question
The minutes of the October 2002 ARG meeting say:
If you violate any Ada semantic requirements in C (by stomping on memory, for
instance), all bets are off.
This is clearly a requirement, as the Ada compiler has no control over what the
foreign language code can do.
However, the only mention of this in the Standard is a note, B.1(49):
An interfacing pragma might result in an effect that violates Ada semantics.
It appears that the standard needs a normative statement to this effect.
!recommendation
(See Wording.)
!wording
Add after B.1(38):
Conventions other than Ada, Intrinsic, entry, and protected
are known as foreign conventions. The effect of a partition containing a
pragma Import, pragma Export, or a pragma Convention with a foreign convention
may differ from that defined by this International Standard.
!discussion
This wording includes pragma Import and Export for all conventions, including
Ada. That's necessary as convention only specifies the calling convention,
while the body of an imported routine (or the caller of an exported routine)
may be written in any language. And that other language could easily violate
Ada semantics.
However, we do not want this wording to cover pragma Convention (Ada). If it
did, a pragma confirming the convention would also allow the compiler to
violate Ada semantics. We do need to include Convention for foreign
conventions, as the calling convention may not include the needed support for
Ada semantics. Imagine an implementation that passes the current innermost
exception handler in a specific register. The C calling convention would
most likely not pass or save that register, and thus exceptions could not
propogate through a C convention call, even if both the caller and called
routine are written in Ada. This seems like a reasonable implementation;
thus, we must not require pragma Convention with a foreign convention to
preserve Ada semantics.
!corrigendum B.1(38)
Insert after the paragraph:
Notwithstanding what this International Standard says elsewhere, the
elaboration of a declaration denoted by the local_name of a pragma
Import does not create the entity. Such an elaboration has no other effect than
to allow the defining name to denote the external entity.
the new paragraph:
Conventions other than Ada, Intrinsic, entry, and protected
are known as foreign conventions. The effect of a partition containing a
pragma Import, pragma Export, or a pragma Convention with a
foreign convention may differ from that defined by this International Standard.
!ACATS test
We can't usefully test if a compiler does this, as it is a permission, not a
requirement.
!appendix
****************************************************************
Questions? Ask the ACAA Technical Agent