Re: [fpc-pascal] memory allocation of dynamic array
On 23 Sep 2007, at 05:18, Marc Santhoff wrote: My question: In which cases will it happen that the memory of a dynamic array is fragmented into multiple non-contiguous blocks? Even if the current implementation allocates dynamic arrays always in one block (I think it does, but I'm not certain), there is probably no guarantee it will stay that way forever (and counting on that may consequently break your program in the future). Counting on implementation details of opaque entities (such as set formats, anything regarding reference counted types such as when references are added or removed and when how many references will exist, rtti format, code generation details such as evaluation order of parameters or operands, memory manager allocation behaviour, ...) is almost 100% guaranteed to break your code at one point or another in time (and often at multiple points in time). Jonas ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] memory allocation of dynamic array
Jonas Maebe a écrit : Counting on implementation details of opaque entities (such as set formats, anything regarding reference counted types such as when references are added or removed and when how many references will exist, rtti format, code generation details such as evaluation order of parameters [...] What do you mean with "evaluation order of parameters"? mm ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] memory allocation of dynamic array
mm schrieb: > Jonas Maebe a écrit : > >> Counting on implementation details of opaque entities (such as set >> formats, anything regarding reference counted types such as when >> references are added or removed and when how many references will >> exist, rtti format, code generation details such as evaluation order >> of parameters [...] > > What do you mean with "evaluation order of parameters"? When doing f(f1(1),f2(2)); there are no assumptions possible if the compiler calls first f1 or f2. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] memory allocation of dynamic array
On 24 Sep 2007, at 14:12, mm wrote: Jonas Maebe a écrit : Counting on implementation details of opaque entities (such as set formats, anything regarding reference counted types such as when references are added or removed and when how many references will exist, rtti format, code generation details such as evaluation order of parameters [...] What do you mean with "evaluation order of parameters"? var a: longint; function f: longint; begin result:=a; a:=a+1; end; procedure test(a,b: longint); begin writeln(a,' ',b); end; begin a:=1; test(f,f); end. The above program can write either "1 2" or "2 1", and what it writes out can change between different compiler versions, platforms and optimization levels (i.e., the parameter evaluation order is undefined). Jonas___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Compiler 2.20 for Arm
> Try to build with -s and examine/post the ppas.sh and link.res file. This is how the ppas.sh and the link.res file looks like. To me it looks ok. Do you think it is an error in the linker. Carsten #!/bin/sh DoExitAsm () { echo "An error occurred while assembling $1"; exit 1; } DoExitLink () { echo "An error occurred while linking $1"; exit 1; } echo Assembling testthreads /Fpc/ArmBin/as -o threads.o threads.s if [ $? != 0 ]; then DoExitAsm testthreads; fi rm threads.s echo Linking threads /Fpc/ArmBin/ld -Map=link.map -dynamic-linker=/lib/ld-linux.so.2 --gc- sections -L. -o threads link.res if [ $? != 0 ]; then DoExitLink threads; fi SEARCH_DIR(/Fpc/Pas/ReleasedUnits/LibArm9/) SEARCH_DIR(/Fpc/Lib/Ulibc/Arm/) SEARCH_DIR(/Fpc/Lib/2.2.0/arm-linux/Fpc/) SEARCH_DIR(/Fpc/Pas/ReleasedUnits/PpuArm9/) SEARCH_DIR(/Fpc/ArmBin/) INPUT( /Fpc/Lib/Ulibc/Arm/cprt0.o threads.o /Fpc/Lib/2.2.0/arm-linux/Fpc/system.o /Fpc/Lib/2.2.0/arm-linux/Fpc/lineinfo.o /Fpc/Lib/2.2.0/arm-linux/Fpc/strings.o /Fpc/Lib/2.2.0/arm-linux/Fpc/objpas.o /Fpc/Lib/2.2.0/arm-linux/Fpc/cthreads.o /Fpc/Lib/2.2.0/arm-linux/Fpc/sysutils.o /Fpc/Lib/2.2.0/arm-linux/Fpc/dos.o /Fpc/Lib/2.2.0/arm-linux/Fpc/baseunix.o /Fpc/Lib/2.2.0/arm-linux/Fpc/unix.o /Fpc/Lib/2.2.0/arm-linux/Fpc/unixtype.o /Fpc/Lib/2.2.0/arm-linux/Fpc/initc.o /Fpc/Lib/2.2.0/arm-linux/Fpc/dl.o /Fpc/Lib/2.2.0/arm-linux/Fpc/unixutil.o /Fpc/Lib/2.2.0/arm-linux/Fpc/syscall.o /Fpc/Lib/2.2.0/arm-linux/Fpc/ctypes.o /Fpc/Lib/2.2.0/arm-linux/Fpc/errors.o /Fpc/Lib/2.2.0/arm-linux/Fpc/sysconst.o ) INPUT( -lulibc -lgcc_s -lpthread -ldl -lc ) ENTRY(_start) ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal