Author Topic: Internal Error 20060521 with latest Lazarus build  (Read 820 times)

Offline eny

  • Imaging User
  • *
  • Posts: 3
    • View Profile
Internal Error 20060521 with latest Lazarus build
« on: 23 July 2010, 23:18:44 »
VIL 264; lazarus daily snapshot 26788 (July 23rd) with FPC 2.4.3 on WinXP SP3.
When adding some units to the uses list (Imaging, ImagingTypes, ImagingClasses, ImagingCanvases) an internal error is raised on line 705 of ImagingPSD.

Offline Galfar

  • Administrator
  • Imaging User
  • *****
  • Posts: 312
    • View Profile
    • Galfar's Homepage
Re: Internal Error 20060521 with latest Lazarus build
« Reply #1 on: 23 July 2010, 23:42:47 »
Report internal compiler error to FPC bug tracker please, there's not much I can do about this.
Or could you try some other FPC versions too?

Offline eny

  • Imaging User
  • *
  • Posts: 3
    • View Profile
Re: Internal Error 20060521 with latest Lazarus build
« Reply #2 on: 30 July 2010, 13:14:03 »
I've found a surprisinlgy simple workaround for this problem.
It seems the compiler is confused by the TLongWordRec usage in SwapEndianLongWord (ImagingUtility.pas) together with a call to this function with a pure constant value parameter:
Code: [Select]
      LongVal := SwapEndianLongWord(16);               // Extra data size (4 (mask size) + 4 (ranges size) + 8 (name))It's perfectly good syntax, but the compiler gets confused and raises an internal error.

I've found 2 different ways of implementing a quick fix that both work (as far as I can see):
1. Create a simple variant record type and use that as a typecast instead of TLongWordRec.
Code: [Select]
TSimpleLWRec = packed record
  B0, B1, B2, B3: byte;
end;
...
  // In SwapEndianLongWord:
  TSimpleLWRec(Result).B0 = TSimpleLWRec(Value).B3;
  TSimpleLWRec(Result).B1 = TSimpleLWRec(Value).B2;
  //etc...

2. Cheat on the compiler by not passing '16' as an argument, but use a local variable instead:
Code: [Select]
      LongVal := 16;
      LongVal := SwapEndianLongWord(LongVal);               // Extra data size (4 (mask size) + 4 (ranges size) + 8 (name))
LongVal is already there and the assignment introduces little overhead.
« Last Edit: 30 July 2010, 18:05:14 by eny »

Offline Galfar

  • Administrator
  • Imaging User
  • *****
  • Posts: 312
    • View Profile
    • Galfar's Homepage
Re: Internal Error 20060521 with latest Lazarus build
« Reply #3 on: 11 August 2010, 16:24:13 »
Thanks for the tip for avoiding internal error.
Have you reported it to FPC bug tracker?