[Aldor-l] Questions
Ralf Hemmecke
ralf at hemmecke.de
Mon Nov 12 11:52:11 EST 2007
So? That should be considered a bug, right? (And it is even terribly
easy to fix by replacing in sal_string.as the line
string(l:Literal):% == string(l pretend Pointer);
by
string(l:Literal):% == copy string(l pretend Pointer);
.)
But there are more than 1200 old bugs missing from the bugtracker, so
why not also this one here...
Ralf
On 11/09/2007 05:47 PM, ldragan at aldor.org wrote:
> Quoting Ralf Hemmecke <ralf at hemmecke.de>:
>
>>>> 2) Can Aldor 1.1 be used with GCC 4.x?
>>>
>>> I do build and use it using gcc 4.0.
>>
>> Oh, but didn't *you* say that there is a problem with "writable strings".
>
> I updated the compiler to compile with gcc 4. The writable string
> "problem" is still there. The idea is that strings constructed from
> literals are not writable. For instance, if you have this program:
>
> --- a.as BEGIN
> #include "aldor"
> #include "aldorio"
>
> import from MachineInteger;
>
> s := "abc";
> stdout << "s before write: " << s << newline;
> s.1 := "x".0;
> stdout << "s after write: " << s << newline;
> --- a.as END
>
> The output is:
> $ aldor -fx -laldor a.as
> $ ./a
> s before write: abc
> Segmentation fault
>
> If you want to write to s, you have to write:
>
> --- b.as BEGIN
> #include "aldor"
> #include "aldorio"
>
> import from MachineInteger;
>
> s := copy("abc"); -- s is a copy of the string literal
> stdout << "s before write: " << s << newline;
> s.1 := "x".0;
> stdout << "s after write: " << s << newline;
> --- b.as END
>
> And the output is:
> $ aldor -fx -laldor b.as
> $ ./b
> s before write: abc
> s after write: axc
>
> --
> Laurentiu
More information about the Aldor-l
mailing list