[Aldor-l] Questions

ldragan at aldor.org ldragan at aldor.org
Fri Nov 9 11:47:26 EST 2007


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