[Ada] Remove predefined equality on hashing context types

Arnaud Charlet charlet@adacore.com
Tue Dec 1 10:25:00 GMT 2009


Context is the internal, implementation defined state of an intermediate state
in a hash computation, and no specific semantics can be expected on equality
of context values. Only equality of final hash values (as returned by the
[Wide_]Digest functions) is meaningful. This change removes the predefined
equality operator on Contexts to ensure that user code that makes errneous
assumptions about the significance of equality of Contexts is detected
at compile time.

The following compilation must be rejected with the indicated error:
$ gcc -c sha1_context_equals.adb
sha1_context_equals.adb:5:14: cannot call abstract subprogram "="

with GNAT.SHA1; use GNAT.SHA1;
function SHA1_Context_Equals return Boolean is
   C1, C2 : Context;
begin
   return C1 = C2;
end SHA1_Context_Equals;

Tested on x86_64-pc-linux-gnu, committed on trunk

2009-12-01  Thomas Quinot  <quinot@adacore.com>

	* g-sechas.ads (GNAT.Secure_Hashes.H."=" on Context): Make abstract.

-------------- next part --------------
Index: g-sechas.ads
===================================================================
--- g-sechas.ads	(revision 154866)
+++ g-sechas.ads	(working copy)
@@ -133,6 +133,13 @@ package GNAT.Secure_Hashes is
       type Context is private;
       --  The internal processing state of the hashing function
 
+      function "=" (L, R : Context) return Boolean is abstract;
+      --  Context is the internal, implementation defined state of an
+      --  intermediate state in a hash computation, and no specific semantics
+      --  can be expected on equality of context values. Only equality of
+      --  final hash values (as returned by the [Wide_]Digest functions below)
+      --  is meaningful.
+
       Initial_Context : constant Context;
       --  Initial value of a Context object. May be used to reinitialize
       --  a Context value by simple assignment of this value to the object.


More information about the Gcc-patches mailing list