← board

AnsiString(fp()) of a function-pointer PChar result mis-lowers — garbage length (SILENT)

Repro

type TPCharFn = function(n: PAnsiChar): PAnsiChar; cdecl;
function getenv(name: PAnsiChar): PAnsiChar; cdecl; external 'libc.so.6';
var fp: TPCharFn; s: AnsiString;
begin
  fp := @getenv;
  s := AnsiString(fp('PATH'));   { garbage length; direct getenv('PATH') is now correct }
end.

fwd(...) (forward-declared) and obj.Method(...) results cast correctly — only the indirect (function-pointer) call fails.

Root

The call is an AN_CALL_IND node (call through a proc-typed value), not AN_CALL. IsNodePChar (ir.inc:1494) enumerates node SHAPES and its case 4 keys on ASTIVal[node] as a procIdx — an indirect call has none, so no case matches → IsNodePChar returns False → the cast reinterprets the raw pointer as a managed handle → bogus length. Yet another shape the enumerator doesn't cover.

Fix

Acceptance

Log