Re: [fpc-devel] Strange Problem!

2012-04-25 Thread Jonas Maebe
On 25 Apr 2012, at 23:53, Amir wrote: >> The reason is that ansistring is an implicit pointer type, unlike >> shortstring. Assigning a constant ansistring to Result means simply that a >> pointer to that series of spaces is copied into the Result pointer. If you >> then start modifying Result

Re: [fpc-devel] Strange Problem!

2012-04-25 Thread Amir
The reason is that ansistring is an implicit pointer type, unlike shortstring. Assigning a constant ansistring to Result means simply that a pointer to that series of spaces is copied into the Result pointer. If you then start modifying Result by hacking behind the compiler's back (which is

Re: [fpc-devel] Strange Problem!

2012-04-25 Thread Martin
On 25/04/2012 21:11, Amir wrote: I am not sure what you mean be "your program is not valid". I am initializing Result. Modify its content and ... I already observed that if I use either shortstring or use indices to modify Result, this problem does not occur. But still I can't see what caus

Re: [fpc-devel] Strange Problem!

2012-04-25 Thread Jonas Maebe
On 25 Apr 2012, at 22:11, Amir wrote: > I am not sure what you mean be "your program is not valid". This is not valid when Result is an ansistring (or unicodestring), at least if you afterwards start writing to Result via the CurDigits pointer: > Result:= ''; > > CurDigit:=

Re: [fpc-devel] Strange Problem!

2012-04-25 Thread Ralf A. Quint
At 01:11 PM 4/25/2012, Amir wrote: I am not sure what you mean be "your program is not valid". I am initializing Result. Modify its content and ... I already observed that if I use either shortstring or use indices to modify Result, this problem does not occur. But still I can't see what cau

Re: [fpc-devel] Strange Problem!

2012-04-25 Thread Amir
I am not sure what you mean be "your program is not valid". I am initializing Result. Modify its content and ... I already observed that if I use either shortstring or use indices to modify Result, this problem does not occur. But still I can't see what causes this problem. And I believe it

Re: [fpc-devel] Strange Problem!

2012-04-25 Thread Flávio Etrusco
You program isn't valid. You're assigning a constant (a global variable) to Result, so you shouldn't change it's contents through a pointer (if you change it normally the compiler+RTL will COW the value). You can use a shortstring or: Result := StringOfChar(' ', 16); -Flávio On Tue, Apr 24, 2012

[fpc-devel] Strange Problem!

2012-04-24 Thread Amir
Hi, I have encountered a strange problem. I developed the following function as a faster implementation for IntToStr: function MyIntToStr (n: Int64): AnsiString; const MaxLength= 16; var CurDigit: PChar; Sign: Boolean; begin Result:= ''; CurDigit:= @(Result [MaxLe

Re: [fpc-devel] Strange problem with -M and -S command-line options

2008-09-22 Thread Aleksa Todorovic
Thanks for the quick reply, I'll make bug-report immediately. On Mon, Sep 22, 2008 at 14:00, Michael Van Canneyt <[EMAIL PROTECTED]> wrote: > > > On Mon, 22 Sep 2008, Aleksa Todorovic wrote: > >> Hi! >> >> >> As you can see, in the third case string is interpreted as >> ShortString, not AnsiString

Re: [fpc-devel] Strange problem with -M and -S command-line options

2008-09-22 Thread Michael Van Canneyt
On Mon, 22 Sep 2008, Aleksa Todorovic wrote: > Hi! > > > As you can see, in the third case string is interpreted as > ShortString, not AnsiString. Is this intended behaviour of compiler, > or command-line processing bug? This is intended behaviour. The Mode switch resets some other switches.

[fpc-devel] Strange problem with -M and -S command-line options

2008-09-22 Thread Aleksa Todorovic
Hi! I've just hit this problem, and wanted to report it, so someone can tell me if this is FPC or Lazarus bug. == Compiler version: 2.2.2 Lazarus version: svn trunk (revision 16671) Description: If -Sh is used before -Mobjfpc on command-line, string is interpreted as ShortString,