[Aldor-l] Compiling setup
Gabriel Dos Reis
gdr at integrable-solutions.net
Thu Aug 10 21:46:47 EDT 2006
"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 =
| >
|
| Rather than "bug" I think it would be more fair to call
| this a "design flaw"... :)
Sorry, I can't call it a "design flaw" :-)
| 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.
| But this does contradict a statement made recently by one
| of (the only?) Aldor compiler developer here on this list.
| How much testing have you done?
| I presumed that the gcc developers removed rewritable-strings
| because this "feature" of the C language is no longer
| supported -- not just because they are "purists", right? ;)
it never was a "feature" of the C language.
The C language explicitly says that it is undefined behaviour to modify
string literals. For many reasons, including security, it is
better for the compiler to honor the spirit and the letter of the C
definition: literal strings cannot be modified.
| So if Aldor can generate C code that violates this restriction,
| it is probably not such a good idea to remove this "gcc-hack"
| until the Aldor developers say it is no longer required. No?
I don't quite understand why this really is a problem. Surely, one
can have string buffers in C programs. So, why is it that Aldor needs
the buffer to be *string literal*? That sounds to me like an internal
logical inconsistency. The generated program cannot be correct.
>From the C standard, section "6.4.5 String literals"
[...]
[#6] It is unspecified whether these arrays are distinct
provided their elements have the appropriate values. If the
program attempts to modify such an array, the behavior is
undefined.
-- Gaby
More information about the Aldor-l
mailing list