Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2007-06

Problem with array [Boolean]

4 messages · 2 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Felipe Monteiro de Carvalho

Hi,

Using fpc 2.1.5 on Mac Intel, I am getting a wierd error on this line:

  Buffers[CurrentBuffer].DrawTo(MainForm.Canvas.Handle, 0,0);

With the following declarations:

  public
    { Public declarations }
    CurrentBuffer : Boolean;
    Buffers: array [Boolean] of TBitmap32;
....

This exception:

TApplication.HandleException Invalid type cast

And this backtrace:

Breakpoint 1, 0x0000e0a6 in fpc_raiseexception ()
(gdb) bt
#0 0x0000e0a6 in fpc_raiseexception ()
#1 0x00056682 in SYSUTILS_RUNERRORTOEXCEPT$LONGINT$POINTER$POINTER () #2 0x00010fd7 in SYSTEM_HANDLEERRORADDRFRAME$LONGINT$POINTER$POINTER () #3 0x0000cf71 in fpc_class_as_intf ()
#4 0x00027ebf in TMAINFORM__TRANSFORMFRAME (SENDER=0xfb3020, DONE=true, this=0xf2c810) at MainUnit.pas:359
#5 0x00022bf4 in TAPPLICATION__IDLE (WAIT=true, this=0xfb3020) at application.inc:299
.....

What kind of typecast is that? I don't see any on the code. And why is fpc_class_as_intf being executed? I don't see any interfaces being used.

This code comes from a delphi example application, and I'm a little lost about what is wrong or how to fix it.

Maybe the sintax array [Boolean] doesn't work and I should substitute it by something like [0..1]

thanks,

Felipe Monteiro de Carvalho
Jonas Maebe
to Felipe Monteiro de Carvalho
Felipe Monteiro de Carvalho wrote 15 lines
Breakpoint 1, 0x0000e0a6 in fpc_raiseexception () (gdb) bt #0 0x0000e0a6 in fpc_raiseexception () #1 0x00056682 in SYSUTILS_RUNERRORTOEXCEPT$LONGINT$POINTER$POINTER () #2 0x00010fd7 in SYSTEM_HANDLEERRORADDRFRAME$LONGINT$POINTER $POINTER () #3 0x0000cf71 in fpc_class_as_intf () #4 0x00027ebf in TMAINFORM__TRANSFORMFRAME (SENDER=0xfb3020, DONE=true, this=0xf2c810) at MainUnit.pas:359 #5 0x00022bf4 in TAPPLICATION__IDLE (WAIT=true, this=0xfb3020) at application.inc:299 ..... What kind of typecast is that? I don't see any on the code. And why is fpc_class_as_intf being executed?

Without compilable example code, that is impossible to say.

Jonas

Felipe Monteiro de Carvalho
to Jonas Maebe
Jonas Maebe wrote
Without compilable example code, that is impossible to say.

Sorry for the noise, I found the problem =)

Inside the DrawTo function code there is a cast to an interface which isn't implemented.

I just suposed that on the backtrace gdb would show exactly where the exception occured. There were more functions called at the point where the exception really happens ... I don't know why he skiped some. Debuging with the IDE step-by-step showed the correct location of the exception.

thanks,

Felipe Monteiro de Carvalho
Jonas Maebe
to Felipe Monteiro de Carvalho
Felipe Monteiro de Carvalho wrote 5 lines
I just suposed that on the backtrace gdb would show exactly where the exception occured. There were more functions called at the point where the exception really happens ... I don't know why he skiped some. Debuging with the IDE step-by-step showed the correct location of the exception.

Maybe optimizations were turned on.

Jonas