Sign in Join

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

Mailing lists / fpc-pascal / 2007-11

Array slices

2 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

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

Christos Chryssochoidis

Hello all,

A while ago in one of the FPC lists I had read that FPC 2.2.0 supports array slices. So I made a program to test this feature:

Show quoted text 16 lines
program Test_Slices; procedure Test(C : array of Integer); begin end; var A : array of Integer; B : array of Integer; begin setLength(A,6); Test(A[2..4]); // This works setlength(B,6); // B := A[4..6] // Compilation error if I uncomment this line end.

The above code, as it is, compiles without problem. However if I uncomment the last line, I get a compilation error:

Show quoted text 23 lines
ChristosComputer:~/workspace/pascal christoschryssochoidis$ fpc Test_Slices.pas Free Pascal Compiler version 2.2.0 [2007/08/30] for i386 Copyright (c) 1993-2007 by Florian Klaempfl Target OS: Darwin for i386 Compiling Test_Slices.pas Fatal: Compilation aborted An unhandled exception occurred at $0010401C : EAbstractError : Abstract method called $0010401C $0013334D $00133098 $00129879 $00129879 $0012A94C $0010401C $000DCD87 $000C13ED $0001B5F5 Error: /usr/bin/ppc386 returned an error exitcode (normal if you did not specify a source file to be compiled) ChristosComputer:~/workspace/pascal christoschryssochoidis$

Are array slices only supported as arguments to subprograms calls? I 'm using FPC 2.2.0 on Mac OS X Intel.

Thanks very much in advance,

C.C.

Reply by email

Daniël Mantione
to Christos Chryssochoidis

Op Sun, 11 Nov 2007, schreef Christos Chryssochoidis:

Show quoted text 24 lines
Hello all, A while ago in one of the FPC lists I had read that FPC 2.2.0 supports array slices. So I made a program to test this feature: > program Test_Slices; > > procedure Test(C : array of Integer); > begin > end; > > var > A : array of Integer; > B : array of Integer; > > begin > setLength(A,6); > Test(A[2..4]); // This works > setlength(B,6); > // B := A[4..6] // Compilation error if I uncomment this line > end. The above code, as it is, compiles without problem. However if I uncomment the last line, I get a compilation error:
Are array slices only supported as arguments to subprograms calls? I 'm using FPC 2.2.0 on Mac OS X Intel.

At this time: yes, you can pass only to open arrays. In the future, the above construction will be supported. It is of course not correct that this causes a compiler crash and this is a bug.

Daniël

Reply by email