Board index » delphi » Delphi 2.0x Compiler Bug (w/src)

Delphi 2.0x Compiler Bug (w/src)

The problem arised when I was porting some code of mine from Delphi 1.03 to
2.01.  Delphi crashes (or rather gives an Application Error) in both the D2
IDE and DCC32.EXE.

I've cleaned out the source as much as possible, while retaining the bug.

The problem seems to be with typed constants, but is interlinked with
conditional defines in some strange way.  

In other words; the compiler seem to end up in a strange state which causes it
to crash... Does that sound familiar, or what? :)  

There are several strange things about this code:

1. If you compile it in BP DOS mode/or DPMI mode, it compiles OK
2. If you compile it in Delphi 1.03, it compiles OK
3. If you remove the TestArrayBug declaration, it compiles OK
6. If you remove the first function, it compiles OK
4. If you remove ANY of the DEFINEs, it compiles OK
5. If you move the CONSTs to the first procedure, it compiles OK

The IDE gave me a dialog with the caption "Error":
Access violation at address 0083FDC7. Read of address 00000003.

The commandline compiler gave me a dialog "DCC32.EXE - Application Error":
The instruction at "0x00438ba7" referenced memory at "0x00000003".The memory
could not be "read".

Another issue is that while the IDE seems to cope with the App.Error,
it really is in a strange state. The editor suddenly become read-only for
some of your project files.
In the original source, if you did a change, and tried to save it, you'd get a
"couldn't save" fault, just as if the previous source file was locked in some
way.

If you, in the IDE, try to compile it again, you get:
C:\SRC\IFDEFBUG.PAS(1): Program or unit recursively uses it self.

I'm lost... Weird, ain't it?

Lars F.

Ex. 1 - As a program (it originally was a unit)
(You can ignore the IDE warning about "invalid uses clause")

{$A+,B-,C-,D+,E-,F-,G+,H+,I+,J+,K-,L+,M-,N+,O+,P+,Q-,R-,S-,T-,U-,V-,W+,X+,Y-,Z1}
PROGRAM IfDefBug;

FUNCTION Proc1(VAR F):Integer;
BEGIN
  {$DEFINE OneDefine}
END;

FUNCTION Proc2(VAR F):Integer;
CONST
  TestArrayBug : ARRAY[0..1] OF Char = 'AB';
  TestArrayOk  : ARRAY[0..1] OF Char = ('A', 'B');
BEGIN
  {$DEFINE AnotherDefine}
END;

BEGIN
END.

Ex. 2 - As a unit

{$A+,B-,C-,D+,E-,F-,G+,H+,I+,J+,K-,L+,M-,N+,O+,P+,Q-,R-,S-,T-,U-,V-,W+,X+,Y-,Z1}
UNIT IDefBug;

INTERFACE

IMPLEMENTATION

FUNCTION Proc1(VAR F):Integer;
BEGIN
  {$DEFINE OneDefine}
END;

FUNCTION Proc2(VAR F):Integer;
CONST
  TestArrayBug : ARRAY[0..1] OF Char = 'AB';
  TestArrayOk  : ARRAY[0..1] OF Char = ('A', 'B');
BEGIN
  {$DEFINE AnotherDefine}
END;

BEGIN
END.

--
/Mr.Lars Fosdal    /Falcon AS   (a REUTERS company)   /Tel.+47 22005734
/lfos...@falcon.no /Stortorvet 10, N0155 OSLO, Norway /Fax.+47 22005777

 

Re:Delphi 2.0x Compiler Bug (w/src)


Quote
Lars Fosdal wrote:
> [...]
> If you, in the IDE, try to compile it again, you get:
> C:\SRC\IFDEFBUG.PAS(1): Program or unit recursively uses it self.

[...]

Quote
> (You can ignore the IDE warning about "invalid uses clause")

[...]

        Well surely this can't be the problem, but what happens
if you don't ignore the warning and insert a valid uses clause?
I know back in the old D1 days I would find myself inserting
do-nothing "uses Wintypes, Winprocs" just to get something
to compile.

--
David Ullrich

?his ?s ?avid ?llrich's ?ig ?ile
(Someone undeleted it for me...)

Re:Delphi 2.0x Compiler Bug (w/src)


My Delphi is the update version of 2.17.76 in the about box using
ALT+Version.

It gives the same problem you described when compiling your test
program. I was interested because I've had Delphi do the same thing to
me under different circumstances. I was unable to isolate the cause of
the bug. The most memorable one, was the program or unit recursively
uses itself message. Which I used to get frequently. The same symptoms,
of unable to modify code in the editor window, access violations when
compiling and the rest.

I am unable to explain what's going on, but your test code is small
enough to be able to pinpoint something, well worth mailing it to
borland, if they don't know about it already.

John B

Re:Delphi 2.0x Compiler Bug (w/src)


Quote
David Ullrich <ullr...@math.okstate.edu> wrote:
> Lars Fosdal wrote:
> > (You can ignore the IDE warning about "invalid uses clause")

>    Well surely this can't be the problem, but what happens
> if you don't ignore the warning and insert a valid uses clause?
> I know back in the old D1 days I would find myself inserting
> do-nothing "uses Wintypes, Winprocs" just to get something
> to compile.

The uses clause, present or absent, has as far as I've tested, no effect on
the problem described.

Lars F.

--
/Mr.Lars Fosdal    /Falcon AS   (a REUTERS company)   /Tel.+47 22005734
/lfos...@falcon.no /Stortorvet 10, N0155 OSLO, Norway /Fax.+47 22005777

Other Threads