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