Oberon Community Platform Forum
December 14, 2019, 05:24:21 AM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: Is it OK?  (Read 3651 times)
darek
Jr. Member
**
Posts: 59


« on: March 25, 2008, 02:41:26 PM »

Dear All,
 I have created a simple module that keeps constant definitions


MODULE Test;

 CONST
     one_kb*                                              =  1024;
      max_vector_size*                                   =  512  *  one_kb ;
      vector_size_4*                                       =  4;
      vector_size_8*                                       =  8;
      vector_size_16*                                     = 16;
      vector_size_32*                                     = 32;
      vector_size_64*                                     = 64;
      vector_size_128*                                   = 128;
      vector_size_256*                                   = 256;
      vector_size_512*                                   = 512;
      vector_size_1k*                                     = one_kb;
      vector_size_2k*                                     = 2   * one_kb;
     
BEGIN

END Test.


when I tried to compile it (WinAos 3.07e/WinXP) I got the following error:

compiling Test not done
   pos  -1  err  280   vector_size_2k  duplicate fingerprint



When the line that contains   vector_size_2k  definition  is commented out, everthing returns to  "normal".

Is this a compiler bug  or just my error ?

Regards,
  Darek
Logged
felix
Administrator
Newbie
*****
Posts: 17



WWW
« Reply #1 on: March 26, 2008, 11:06:53 AM »

Hi Darek,
first of all: it is not your error. But it's not really a compiler bug either.

As fingerprinting is used for the version control of symbol files, two symbols in the same symbol file must have different fingerprints for several reasons. One reason is that in the computation of the fingerprints for procedures, the parameters (and types thereof) of the procedure are also included. Exchanging the type of a parameter in a procedure must, however, result in a different fingerprint. Therefore different types must have different fingerprints. This rule applies to all symbols (which might be not completely necessary, I can't say).

Although highly improbable (I have not seen this before in many years of programming Oberon), it is possible that symbols with different names and values can have the same fingerprint. The reason is that the one-way hash functions used to compute the (32bit) fingerprint are not really injective but collisions are possible. In the case example that you wrote, there is such a collision that already occurs in the following module.

MODULE Test;
 CONST
      vector_size_1k*                                     = 1024;
      vector_size_2k*                                     = 2048;     
END Test.

A way to make this problem less probable would be to use a different hash functions (for example MD5 hashing). Although it sounds a bit like a hack, as it does not happen really frequently I recommend to just rename the variables (for example vector_size_1kb, vector_size_2kb).

Best,
Felix
Logged
darek
Jr. Member
**
Posts: 59


« Reply #2 on: March 26, 2008, 12:56:44 PM »

Felix,
  thank you very much for your very detailed answer. I will modify my code according  to your suggestion.

  I did a short  test with the Component Pascal (BlackBox, v.1.6 )  compiler. It compiles this code without any problems.
 
  Regards,
   Darek

 
 
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines Valid XHTML 1.0! Valid CSS!