Re: [cc65] Problem with code compiled as overlay.

From: Groepaz <groepaz1gmx.net>
Date: 2012-01-22 18:53:27
On Sunday 22 January 2012, Ullrich von Bassewitz wrote:
> On Sun, Jan 22, 2012 at 03:07:41AM +0100, Groepaz wrote:
> > eh, so something like
> > 
> > char *foo = "abc";
> > 
> > foo[1] = 'B';
> > 
> > is undefined?
> 
> No. We're talking about string literals. So
> 
>         "abc"[1] = 'd';
> 
> is legal in the sense that it is translated by the compiler, but the
> behaviour is undefined when executed. This has history reasons. String
> literals were of type "char*" a long time ago. And since they were
> actually writable, people relied on that. Newer versions of the standard
> could not change the type without making almost every old source
> uncompilable, so they kept the type being "char*" but prohibited writing
> to the literal. To allow this practice, which was common in very old
> sources, some compilers (like gcc) have an option that places these
> strings into the data segment.

ok, thanks for the explaination :)

-- 

http://www.hitmen-console.org    http://magicdisk.untergrund.net
http://www.pokefinder.org        http://ftp.pokefinder.org

Wem bewusst ist, dass er im Atomzeitalter lebt, und sich dem 
Militaerdienstzwang trotzdem nicht widersetzt, gedankenlos in die Kasernen 
trottet, obwohl er den Kriegsdienst verweigern kann - den kann ich nicht 
einmal mehr bedauern. Er hat nur durch einen Irrtum sein Grosshirn bekommen, 
das Rueckenmark haette ihm vollkommen genuegt. 
<Albert Einstein>

----------------------------------------------------------------------
To unsubscribe from the list send mail to majordomo@musoftware.de with
the string "unsubscribe cc65" in the body(!) of the mail.
Received on Sun Jan 22 18:53:38 2012

This archive was generated by hypermail 2.1.8 : 2012-01-22 18:53:41 CET