Friday, January 7, 2011

Delphi compiler crash because of faulty DPR code

Recently I wanted to test some things and I wanted to comment some of the units used in my project, in the DRP file. Unfortunately, I forgot to close the comment (close bracket}) so I commented too much code in that DPR. As soon as I compiled the project I got an access violation in module dcc70.dll.

After a while I figured out the problem and closed the comment. Yes, instead of showing there is a problem in the code, the compiler just AVed. Delphi compiler is very happy since I fixed the comment.
I seems this also can appear when you have invalid code in the top of the unit (in the INTERFACE section) or when you have strange programming errors (also typos) in code. 

Other people reported problems with code like this: 

procedure aa;
var
  sn:string;
  xx:double;
  err:integer;
begin
    system.Val(sn,xx,err); // this caused the AV problem !!!
end; 

or 

const
  SeparatorIndices: array(1..7) of integer = (6, 13, 39, 65, 72, 75, 76);

instead of the correct code:
const
  SeparatorIndices: array[1..7] of integer = (6, 13, 39, 65, 72, 75, 76);


The solution is to comment pieces of code until the compiler starts to work again, then un-comment and see where the problem is.


No comments:

Post a Comment