[Aldor-l] Compiling setup
Christian Aistleitner
tmgisi at gmx.at
Fri Aug 11 05:59:26 EDT 2006
Hello,
On Fri, 11 Aug 2006 03:46:47 +0200, Gabriel Dos Reis
<gdr at integrable-solutions.net> wrote:
> "Page, Bill" <Bill.Page at drdc-rddc.gc.ca> writes:
>
> | On Thursday, August 10, 2006 8:56 PM Gabriel Dos Reis wrote:
> |
> | > ...
> | > What you have to do is that you need to modify the variable
> | > gcc-hacks from section [gcc] of /usr/local/aldor/linux/
> | > 1.0.3/aldor.conf not to include -fwritable-strings. There
> | > is an obscure comment about why that flags is needed.
> | >
> | > Mine now reads:
> | >
> | > # On some platforms string literals are stored in read-only
> | > segments.
> | > # This causes problems when users write Aldor programs in
> | > which a
> | > # string literal is used as a buffer. The result is a
> | > segfault that
> | > # is extremely hard to track down, even for experienced
> | > Aldor coders.
> | > # GDR: Well, either that is a bug in Aldor, or a bug in
> | > those experienced
> | > # GDR: aldor coders' programs. At any rate, that option
> | > is no
> | > # longer supported.
> | > # gcc-hacks = -fwritable-strings
> | > gcc-hacks =
> | >
> |
[...]
>
> | Does your change to aldor.conf actually work?? If so great!
>
> For the little programs I've tried, yes it *seems* to work.
> It is either that, or no Aldor program at all.
Just consider the attached test.as. It does just the dangerous thing (as
described in the aldor.conf) -- modifying an Aldor String constant.
Consider the following output with writable strings:
____________________________________________
tmgisi at spencer
cwd: ~/aldor
$ grep gcc-hacks.*= /opt/aldor/include/aldor.conf ; LC_ALL=C
/opt/aldor/bin/aldor \
-M no-abbrev -C args=-Wopts=-m32 -Fx -laldor test.as && ./test
gcc-hacks = -fwritable-strings
cc1: note: -fwritable-strings is deprecated; see documentation for details
cc1: note: -fwritable-strings is deprecated; see documentation for details
abcdefghij
abcXefghij
And now without writable strings
____________________________________________
tmgisi at spencer
cwd: ~/aldor
$ grep gcc-hacks.*= /opt/aldor/include/aldor.conf ; LC_ALL=C
/opt/aldor/bin/aldor \
-M no-abbrev -C args=-Wopts=-m32 -Fx -laldor test.as && ./test
gcc-hacks =
abcdefghij
Speicherzugriffsfehler
So at least for this simple file, it does not work. Of course you can
rewrite the Aldor code to make it work. The provided test.as shows
"-fwritable-strings" is not just a relict in the aldor.conf file, but it
is actually needed.
*Please* do *not* omit "-fwritable-strings", for your own sake.
Instead:
1. get an old enough compiler (wherever this is possible), so you can
compile the programs and
2. keep mocking about the issue.
However, you might also consider my test.as to be of extremely miserable
style.
After all, I am assigning a constant ("abcdefghij") to a variable (a).
Afterwards I use a destructive function( set! via a.3) on the variable
(actually, the constant "abcdefghij"). Replacing
local a: String := "abcdefghij";
by
local a: String := copy "abcdefghij";
gives code that's working even without -fwritable-strings.
On another layer the test.as's "abcdefghij" is a constant. However,
implicitly, the constant is fed to the
string: Literal -> String
function from the String domain. Actually (ignoring the implementation of
the string function), the constant "abcdefghij" is not used directly, but
only the result of passing the constant to a function is used and modified
via "a.3". (Of course, due to the implementation of string$String,
"abcdefghij" and the variable a are the same thing, but that's a different
issue) So shouldn't string$String declare it generates memory aliases?
The question is about "What is considered bad style?".
aldor.conf explicitly deals with the issue of whether string literals are
read-only or not, so I doubt that Aldor compiler developers consider it
bad style.
--
Kind regards,
Christian
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test.as
Type: application/octet-stream
Size: 182 bytes
Desc: not available
Url : http://aldor.org/pipermail/aldor-l_aldor.org/attachments/20060811/cb4d178f/attachment.obj
More information about the Aldor-l
mailing list