Watch, Follow, &
Connect with Us
Public Report
Report From: Delphi-BCB/Compiler/Delphi/Language    [ Add a report in this area ]  
Report #:  10620   Status: Closed
Open arrays of Char/WideChar does not accept Dynamic arrays of same type
Project:  Delphi Build #:  7.0.4.453
Version:    7.0 Submitted By:   Carlos Beppler
Report Type:  Basic functionality failure Date Reported:  1/26/2005 9:08:11 AM
Severity:    Serious / Highly visible problem Last Updated: 3/20/2012 2:24:39 AM
Platform:    All versions Internal Tracking #:   219359
Resolution: Retest (Resolution Comments) Resolved in Build: : 7.0.4.453
Duplicate of:  None
Voting and Rating
Overall Rating: (1 Total Rating)
4.00 out of 5
Total Votes: None
Description
I can pass an dynamic array to a routine expecting open arrays, but it fails when the base type of the arrays is Char/WideChar.

This code compiles:

procedure Clear(var A: array of Integer);
var
  I: Integer;
begin
  for I := 0 to High(A) do A[I] := 0;
end;

procedure Test;
var x: array of Integer;
    y: Integer;
begin
  SetLength(x,10);
  Clear(x);
  Clear(y);
end;


But this does not (generates incompatible types Array and dynamic array):

procedure Clear(var A: array of Char);
var
  I: Integer;
begin
  for I := 0 to High(A) do A[I] := #0;
end;

procedure Test;
var x: array of Char;
    y: Char;
begin
  SetLength(x,10);
  Clear(x);
  Clear(y);
end;
Steps to Reproduce:
Compile the attached program below with dcc32.

See the following compile time error.

Error: E2010 Incompatible types: 'Array' and 'dynamic array

program Test;

procedure P(const A: array of Char);
begin
end;

procedure Demo;
var
  A: array of Char;
begin
  P(A);
end;


begin
end.

Workarounds
None
Attachment
None
Comments

Carlos Beppler at 1/26/2005 9:19:48 AM -
Theis is a small erros on description, on second example the test procedure should be:

procedure Test;
var x: array of Char;
    y: Char;
begin
  SetLength(x,10);
  Clear(x);
  Clear(y);
end;

Server Response from: ETNACODE01