[fpc-devel] Error compiling trunk on FreeBSD

2011-03-01 Thread Leonardo M . Ramé
Hi, I'm trying to compile the r17057 on FreeBSD x86_64 and I'm getting this error: fpc/rtl/units/x86_64-freebsd/cpu.s:40: Error: no such instruction: `cmpxchg16b (%r8) Any hint? ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://list

[fpc-devel] Error compiling trunk on FreeBSD

2011-03-01 Thread Leonardo M . Ramé
Hi, I'm trying to compile the r17057 on FreeBSD x86_64 and I'm getting this error: fpc/rtl/units/x86_64-freebsd/cpu.s:40: Error: no such instruction: `cmpxchg16b (%r8) Any hint? ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://list

[fpc-devel] GetMem(SomePointer, 0) <> nil

2011-03-01 Thread Paul Ishenin
Hello, FPC developers' list. I noticed today that if I want to allocate 0 bytes I get not a nil but a valid pointer. Why? This is incompatible with delphi. And I suppose cause crashes and memory leaks not only in my delphi code which I'm porting to FPC/Lazarus. -- Best regards, Paul Ishenin

Re: [fpc-devel] GetMem(SomePointer, 0) <> nil

2011-03-01 Thread Michael Van Canneyt
On Tue, 1 Mar 2011, Paul Ishenin wrote: Hello, FPC developers' list. I noticed today that if I want to allocate 0 bytes I get not a nil but a valid pointer. Why? This is incompatible with delphi. And I suppose cause crashes and memory leaks not only in my delphi code which I'm porting to

Re: [fpc-devel] GetMem(SomePointer, 0) <> nil

2011-03-01 Thread Felipe Monteiro de Carvalho
On Tue, Mar 1, 2011 at 1:20 PM, Michael Van Canneyt wrote: > Does it say in the Delphi docs that Nil is returned if Size=0 ? Not in the online ones: http://docwiki.embarcadero.com/VCL/en/System.GetMem -- Felipe Monteiro de Carvalho ___ fpc-devel mail

Re: [fpc-devel] GetMem(SomePointer, 0) <> nil

2011-03-01 Thread Jonas Maebe
On 01 Mar 2011, at 07:32, Paul Ishenin wrote: I noticed today that if I want to allocate 0 bytes I get not a nil but a valid pointer. Why? The current code that causes this comes from this (cvs) revision: revision 1.16 date: 1999-09-17 19:14:12 +0200; author: peter; state: Exp; lines:

Re: [fpc-devel] GetMem(SomePointer, 0) <> nil

2011-03-01 Thread Paul Ishenin
01.03.2011 19:20, Michael Van Canneyt wrote: Well, in all these years, you're the first to notice, so I'm not inclined to think it is a big problem. Does it say in the Delphi docs that Nil is returned if Size=0 ? I don't know but a simple test shows this. Best regards, Paul Ishenin __

Re: [fpc-devel] GetMem(SomePointer, 0) <> nil

2011-03-01 Thread Paul Ishenin
01.03.2011 19:29, Jonas Maebe wrote: That sounds very much like badly written code. For simplicity we had the next code: GetMem(SomeArray, Count * SizeOf(ArrayCell)) if SomeArray <> nil then DoSomeLogic; Best regards, Paul Ishenin ___ fpc-devel mail

Re: [fpc-devel] GetMem(SomePointer, 0) <> nil

2011-03-01 Thread Sergei Gorelkin
Jonas Maebe пишет: On 01 Mar 2011, at 07:32, Paul Ishenin wrote: I noticed today that if I want to allocate 0 bytes I get not a nil but a valid pointer. Why? The current code that causes this comes from this (cvs) revision: revision 1.16 date: 1999-09-17 19:14:12 +0200; author: peter; sta

Re: [fpc-devel] GetMem(SomePointer, 0) <> nil

2011-03-01 Thread Hans-Peter Diettrich
Paul Ishenin schrieb: I noticed today that if I want to allocate 0 bytes I get not a nil but a valid pointer. Why? This will allow for a following Realloc. Even in Delphi the behaviour may be subject to the installed memory manager. DoDi ___ fpc-d

Re: [fpc-devel] GetMem(SomePointer, 0) <> nil

2011-03-01 Thread Marc Weustink
Hans-Peter Diettrich wrote: Paul Ishenin schrieb: I noticed today that if I want to allocate 0 bytes I get not a nil but a valid pointer. Why? This will allow for a following Realloc. Since the resulting pointer of a realloc isn't guarantied the same as the source pointer, I don't see a pr

Re: [fpc-devel] GetMem(SomePointer, 0) <> nil

2011-03-01 Thread Jonas Maebe
On 01 Mar 2011, at 15:25, Sergei Gorelkin wrote: > Jonas Maebe пишет: >> a) give a run time error if someone tries to do freemem(nil) > > Delphi allows freemem(nil) without error, consistent with TObject.Free I don't think TObject.Free and freemem are really comparable. TObject.Free is much mo

Re: [fpc-devel] GetMem(SomePointer, 0) <> nil

2011-03-01 Thread Micha Nelissen
Paul Ishenin wrote: 01.03.2011 19:29, Jonas Maebe wrote: That sounds very much like badly written code. For simplicity we had the next code: GetMem(SomeArray, Count * SizeOf(ArrayCell)) if SomeArray <> nil then DoSomeLogic; DoSomeLogic ... with a Count = 0, right? or was Sizeof(...) = 0? :-

Re: [fpc-devel] GetMem(SomePointer, 0) <> nil

2011-03-01 Thread Vinzent Höfler
On Tue, 01 Mar 2011 22:19:38 +0100, Micha Nelissen wrote: Paul Ishenin wrote: 01.03.2011 19:29, Jonas Maebe wrote: That sounds very much like badly written code. For simplicity we had the next code: GetMem(SomeArray, Count * SizeOf(ArrayCell)) if SomeArray <> nil then DoSomeLogic; DoSo

Re: [fpc-devel] GetMem(SomePointer, 0) <> nil

2011-03-01 Thread Jonas Maebe
On 01 Mar 2011, at 22:58, Vinzent Höfler wrote: > What I wonder is, if GetMem returns a non-NIL, valid pointer for a request > of zero bytes of memory, where does this pointer actually point to? ;) To a small, non-zero sized memory block. Jonas___ fp

Re: [fpc-devel] Error compiling trunk on FreeBSD

2011-03-01 Thread Alexander Klenin
On Tue, Mar 1, 2011 at 03:07, Leonardo M. Ramé wrote: > Hi, I'm trying to compile the r17057 on FreeBSD x86_64 and I'm getting this > error: > > fpc/rtl/units/x86_64-freebsd/cpu.s:40: Error: no such instruction: > `cmpxchg16b (%r8) > > Any hint? It seems you should upgrade your assembler/binuti

Re: [fpc-devel] GetMem(SomePointer, 0) <> nil

2011-03-01 Thread Alexander Klenin
On Wed, Mar 2, 2011 at 01:01, Hans-Peter Diettrich wrote: > Paul Ishenin schrieb: > >> I noticed today that if I want to allocate 0 bytes I get not a nil but a >> valid pointer. Why? > > This will allow for a following Realloc. > > Even in Delphi the behaviour may be subject to the installed memor

Re: [fpc-devel] GetMem(SomePointer, 0) <> nil

2011-03-01 Thread Paul Ishenin
02.03.2011 7:23, Alexander Klenin wrote: Maybe {$mode delphi} should by default install dephi-compatible memory manager? No. Different units cannot install different memory managers. This will be even more dangerous than to be just incompatible with delphi. Best regards, Paul Ishenin _

Re: [fpc-devel] GetMem(SomePointer, 0) <> nil

2011-03-01 Thread Alexander Klenin
On Wed, Mar 2, 2011 at 10:28, Paul Ishenin wrote: > 02.03.2011 7:23, Alexander Klenin wrote: >> >> Maybe {$mode delphi} should by default install dephi-compatible memory >> manager? > > No. Different units cannot install different memory managers. This will be > even more dangerous than to be just

Re: [fpc-devel] GetMem(SomePointer, 0) <> nil

2011-03-01 Thread Paul Ishenin
02.03.2011 5:24, Jonas Maebe wrote: To a small, non-zero sized memory block. Memory allocation is time cost. Either user code should compare that for the zero bytes it should not call a GetMem or GetMem can compare this for user. Since GetMem already has a condition which compares for 0 - it