The remaining incompatibilities which are considered very unlikely to occur in normal programs are briefly considered in 4.6.
The reader should note that we say that an incompatibility is consistent if the worst that can happen is that a legal Ada 83 program becomes illegal in Ada 95 and thus fails to compile. An incompatibility is said to be inconsistent if the program can remain legal but have a different meaning.
Six new reserved words are introduced in Ada 95:
abstract, aliased, protected,
requeue, tagged, and until.
In Ada 95, the type Character has 256 positions. In
Ada 83, it had 128 positions.
In Ada 95, library unit packages are allowed to have a body
only if required by language rules. This avoids a nasty and not so rare error.
Ada 95 provides new syntax for a generic formal private type to
indicate that the actual subtype is allowed to be indefinite. The old syntax
is retained, but the meaning is changed to require definite actual
parameters.
In Ada 95, the exception Numeric_Error is declared in
the package Standard as a renaming of Constraint_Error.
which is the currently recommended way of avoiding the confusion
between Numeric_Error and Constraint_Error in Ada 83.
It is considered that other incompatibilities will be unlikely
to occur in normal programs -- the Ada 83 semantics being known only to the
most erudite of Ada programmers -- and so only a brief description seems
appropriate in this document. In the following summary, they are grouped
according to whether they result in a legal Ada 95 program but with different
semantics; whether they would be detectable by an Ada 95 compiler and so on.
4.6.1 Unlikely Inconsistencies
These incompatibilities might cause a change in the runtime
behavior, but they are not thought likely to occur in normal programs.
Derived type inherits all operations of parent --
These incompatibilities cause a legal Ada 83 program to be an
illegal Ada 95 program and hence are detectable at compile time. They are
considered to be unlikely in normal programs.
Bad pragmas illegal --
4.6.4 Error Incompatibilities
These incompatibilities only occur in programs containing
runtime errors, either detectable (an exception is raised) or undetectable (the
execution is erroneous).
Exceeding 'First or 'Last of an unconstrained floating point
type --
This chapter has outlined the incompatibilities between Ada 83
and Ada 95. As we have seen, the small number that are likely to occur in
practice are easily overcome. The remainder are unlikely to be encountered in
normal programs but have been mentioned for completeness. For further details
the reader should consult the comprehensive discussion in [Taylor 95] upon
which this discussion has been based.
4.1 Reserved Words
4.2 Type Character
type Char_Kind is (Numeric, Alphabetic, Other);
Kind_Array: array (Character) of Char_Kind := -- (1)
('0' .. '9' => Numeric,
'A' .. 'Z' | 'a' .. 'z' => Alphabetic,
others => Other);
case Char is -- (2)
when Character'Val(0) .. Character'Val(63) => ...
when Character'Val(64) .. Character'Val(127) => ...
end case;
I: Integer := Character'Pos(Character'Last); -- (3)
4.3 Library Package Bodies
package Optional_Body is
Global_Variable: Integer;
end Optional_Body;
-----------------------------------------
with Integer_Function;
package body Optional_Body is
begin
Global_Variable := Integer_Function;
end Optional_Body;
4.4 Indefinite Generic Parameters
generic
type Element_Type is private;
package Stack is ...
------------------------------------------------------
with Stack;
package String_Stack is new Stack(Element_Type => String);
generic
type Element_Type is private; -- !! (<>) in Ada 95
package Stack ...
4.5 Numeric Error
exception
when Constraint_Error => Action_1;
when Numeric_Error => Action_2;
end;
are illegal in Ada 95. Moreover, an inconsistency will arise if a
frame has an explicit handler for Numeric_Error or
Constraint_Error but not both as in the following
exception
when Constraint_Error => Action_1;
when others => Action_2;
end;
since Numeric_Error will be caught by the first handler in
Ada 95 but by the second in Ada 83.
4.6 Other Incompatibilities
In Ada 95 a derived type inherits all its parent's primitive operations
previously declared in the same declarative part. In Ada 83, it did not.
Floating point types may have less precision --
the chosen representation for a floating point type may have less
precision in Ada 95 for hardware with a non-binary radix.
Fixed point types may have less precision --
the chosen representation for a fixed point type may have less precision
in Ada 95. This is related to the next item.
Default Small for fixed point types --
In Ada 83, the default value of Small was defined to be the
largest power of two not exceeding S'Delta. In Ada 95, it is
allowed to be a smaller power of two.
Rounding from real to integer is deterministic --
Rounding is defined in Ada 95 as away from zero if the real number is
midway between two integers.
Evaluation order of defaulted generic actual parameters --
The order of evaluation of defaulted generic actuals is arbitrary in Ada 95.
Static expressions evaluated exactly --
Static expressions are always evaluated exactly in Ada 95. In Ada 83
this was only required in a static context.
4.6.2 Unlikely Incompatibilities
In Ada 95, a pragma with an error in its arguments makes the compilation
illegal. In Ada 83, it was ignored.
S'Base not defined for composite subtypes --
In Ada 95, S'Base is not defined for a composite subtype
S.
Wide_Character shares all character literals --
As a result of adding types Wide_Character and
Wide_String to package Standard, Ada 95 character
literals are always overloaded and Ada 95 string literals are always
overloaded.
Definition of freezing tightened --
In Ada 95, range constraints on a type after its declaration and in
occurrences in pragmas freeze the representation (are treated as forcing
occurrences). In Ada 83 they were not treated as forcing occurrences.
Static matching of subtypes --
In Ada 95, matching of subtypes is now performed statically instead of at
runtime (as in Ada 83) in array conversions and generic instantiations.
Illegal to use value of deferred constant --
In Ada 95 it is illegal to use the value of a deferred constant before it
is set. In Ada 83 it was erroneous.
Explicit constraints in uninitialized allocators designating access types --
in Ada 95 such constraints are illegal; in Ada 83 they were ignord.
Exceptions in static expressions illegal --
in Ada 95, it is illegal to raise an exception in a static expression;
in Ada 83 it made the expression non-static.
Preference for universal numeric operators --
In Ada 95, the overload resolution rules have been changed to simplify
them. As a consequence certain pathological Ada 83 programs become
illegal.
Assume worst when checking generic bodies --
Ada 83 generic contract model violations have been overcome in Ada 95 by
assuming the worst case in a generic body.
New identifiers added to package System --
New identifiers in package System may introduce illegalities into
a unit having a use clause for System.
Append_Mode added to File_Mode enumeration --
In Ada 95, subtype File_Mode in packages Sequential_IO
and Text_IO has an extra literal, Append_Mode.
New identifiers added to package Text_IO --
New identifiers in package Ada.Text_IO may introduce illegalities
into a unit having a use clause for Text_IO.
New identifiers added to package Standard --
New identifiers in package Standard may clash with existing
use-visible identifiers.
Functions returning local variables containing tasks --
In Ada 95 it is illegal or raises Program_Error if a function
with a result type with a task subcomponent returns a local variable. In
Ada 83 it was erroneous to return a variable containing a local task.
Illegal to change representation of types containing tasks --
In Ada 95, it is illegal to give a representation item for a derived type
containing a task.
Character literals always visible --
In Ada 95, character literals are visible everywhere. In Ada 83 they
followed the usual rules of visibility.
4.6.3 Implementation Dependent Incompatibilities
These incompatibilities only arise with some implementations.
They occur either as a result of tightening up Ada semantics or where an Ada 83
implementation has used an identifier now predefined in Ada 95. In the latter
case, an inconsistency could occur if the Ada 83 use of the identifier is
compatible with the Ada 95 use, though this is unlikely.
Real attributes replaced --
The Ada 83 attributes for a real subtype S (such as
S'Mantissa) have been replaced by Ada 95 attributes defined in
the Numerics Annex.
Certain pragmas removed --
Some pragmas (including Interface and Shared) have been
removed from the language and Priority has been moved to the
Real-Time Systems annex.
New pragmas defined --
The names of new pragmas may clash with implementation-defined pragmas.
New attributes defined --
The names of new attributes may clash with implementation-defined
attributes.
New library units defined --
The names of new (language-defined) library units may clash with
user-defined or implementation-defined library units.
In Ada 95, the 'First and 'Last of a floating point type
declared without a range constraint are treated as minimum bounds and may
be exceeded without causing Constraint_Error.
Dependent compatibility checks performed on object declaration --
In Ada 95, dependent compatibility checks are performed on object
declaration. In Ada 83, they were performed on subtype declaration.
Implicit array subtype conversion --
Ada 95 allows sliding in more situations than did Ada 83, so
Constraint_Error might not be raised as in Ada 83.
Lower bound of catenation changed for constrained array types --
In Ada 95, the lower bound of the result of catenation for a constrained
array type is defined to be 'First of the index subtype. In Ada
83, the lower bound of the result was 'First of the left operand.
Raising Time_Error deferred --
In Ada 95, raising Time_Error can be deferred until Split or Year is called, or might not be raised at all. In Ada 83, it
is raised on "+" or "-".
Data format for Get --
In Ada 95, Get for real types accepts a wider range of formats
which would raise Data_Error in Ada 83. Leading and trailing
zeros and the radix point are not required.
4.7 Conclusion