[fpc-devel] inline/with

Gerhard Scholz gs at g--s.de
Mon Jun 13 11:21:24 CEST 2005


22:55:42,18 P:\@\Eigen\fp\fmtbcd>del withstat.exe

22:55:42,19 P:\@\Eigen\fp\fmtbcd>ppc386 -Op1 -al -gl         withstat
Free Pascal Compiler version 2.1.1 [2005/05/25] for i386
Copyright (c) 1993-2005 by Florian Klaempfl
Target OS: Win32 for i386
Compiling withstat.pas
withstat.pas(20,50) Warning: Comment level 2 found
Assembling withstat
Linking withstat.exe
42 Lines compiled, 1.6 sec
withstat.pas(19,12) Error: Compilation aborted
An unhandled exception occurred at $00000000 :
EAccessViolation : Access violation
  $00000000
  $004C96DD  TWITHNODE__DESTROY,  line 851 of nmem.pas
  $00546AF9
  $0045CF4E  TUNARYNODE__DESTROY,  line 848 of node.pas
  $0045D4BF  TBINARYNODE__DESTROY,  line 962 of node.pas
  $00546AF9
  $004C63FF  TBLOCKNODE__DESTROY,  line 374 of nbas.pas
  $00546AF9
  $0044643F  TPROCDEF__DESTROY,  line 3886 of symdef.pas
  $00546AF9
  $0040C51E  TINDEXARRAY__CLEAR,  line 1974 of cclasses.pas
  $0040C3F4  TINDEXARRAY__DESTROY,  line 1951 of cclasses.pas
  $0043247D  TSYMTABLE__DESTROY,  line 192 of symbase.pas
  $00546AF9
  $0041AE22  TMODULE__DESTROY,  line 526 of fmodule.pas
  $0047C520  TPPUMODULE__DESTROY,  line 136 of fppu.pas
  $00546AF9

The program:

{$define withWITH}

{$define some_inlines}

{$r+,q+}

{$define integ64}

PROGRAM WithStat ;

  CONST
    MaxFmtBCDFractionSize = 64 ;

  TYPE
    myIntType = {$ifdef integ32} LongInt {$endif} {$ifdef integ64} int64
{$endif} ;

  TYPE
    pBCD = ^ tBCD ;
    tBCD = PACKED RECORD
      Precision : 0..maxfmtbcdfractionsize ;  { 1{joke?}..64 }
      SignSpecialPlaces : Byte ;      { Sign:1, Special:1, Places:6 }
      Fraction : PACKED ARRAY [ 0..( MaxFmtBCDFractionSize DIV 2 ) - 1 ] OF
Byte ;
     END;

  CONST
    NegBit = $80 ;

  PROCEDURE BCDNegate ( VAR BCD : tBCD ) ; {$ifdef some_inlines} INLINE ;
{$endif}

    BEGIN
{$ifdef withWITH}
      WITH BCD DO
       IF Precision <> 0
        THEN SignSpecialPlaces := SignSpecialPlaces XOR NegBit ;
{$else}
      IF BCD.Precision <> 0
       THEN BCD.SignSpecialPlaces := BCD.SignSpecialPlaces XOR NegBit ;
{$endif}
     END ;

  BEGIN
   END.

The error does not occur if either the "withWITH" or the "some_inlines"
stays undefined.

With other words, the combination of WITH-statement and INLINE is unhealthy.

Gerhard

-------------- next part --------------
A non-text attachment was scrubbed...
Name: withstat.pas
Type: application/octet-stream
Size: 882 bytes
Desc: not available
URL: <http://lists.freepascal.org/pipermail/fpc-devel/attachments/20050613/fdffad40/attachment.obj>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: protocol.txt
URL: <http://lists.freepascal.org/pipermail/fpc-devel/attachments/20050613/fdffad40/attachment.txt>


More information about the fpc-devel mailing list