Weird, I wouldn't expect OBJFPC mode to allow automatic conversion
from AnsiString to Pointer...

-Flávio

On 5/12/06, Vinzent Hoefler <[EMAIL PROTECTED]> wrote:
Just found a bug of mine I was wondering about since about three days,
and wanted to share the fun with you:

-- 8< --

// "How to raise the wrong exception" or
// "Why automatic type conversion really sucks"

{$MODE OBJFPC}

program
   Exception_Fun;


uses
   SysUtils;


function Exception_Message : AnsiString;
begin
   exit ('Will never show up, of course.');
end {Exception_Message};

type
   Not_Now = class (SysUtils.Exception);

begin
   try
      raise Not_Now (Exception_Message);
   except
      on e : Not_Now do
         WriteLn (StdErr, 'Caught it! Strange.');
   end {try};
end {Exception_Fun}.

-- 8< --

No error, no warning, no note, no hint: Of course, a class type is just
a pointer, AnsiStrings can be pointers. Pointers can be converted to
any other pointer type... *crash*

_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Reply via email to