Valters Vingolds wrote:
> I run Windows 200 beta 3.
>
> I saw crashes in MusicBrowser.ui (while in process of adding files), of "Memory
> can't be written" type.
> These are because of char *szDrive = "X:" and then szDrive[0]='A'+i; Appears
> that windows does make szDrive a pointer to read-only memory.
> All char *szDrive = "X:" and similar declarations where one intends to later
> write to that pointer should be replaced to char szDrive[]="X:" type
> declaration.
>
> Just ask anyone who codes for OS with "decent" memory protection :) ...
Yup...Windows is perfectly justified in doing what they're doing. I'm
surprised nobody ran into this crash before.
The C++ standard (section lex.string) states:
---------------------------------------snip------------------------------
1 A string literal is a sequence of characters (as defined in
_lex.ccon_) surrounded by double quotes, optionally beginning with the
letter L, as in "..." or L"...". A string literal that does not begin
with L is an ordinary string literal, also referred to as a narrow
string literal. An ordinary string literal has type "array of n const
char" and static storage duration (_basic.stc_), where n is the size
of the string as defined below, and is initialized with the given
characters. A string literal that begins with L, such as L"asdf", is
a wide string literal. A wide string literal has type "array of n
const wchar_t" and has static storage duration, where n is the size of
the string as defined below, and is initialized with the given charac-
ters.
2 Whether all string literals are distinct (that is, are stored in
nonoverlapping objects) is implementation-defined. The effect of
attempting to modify a string literal is undefined.
---------------------------------------snip------------------------------
The effect of attempting to modify a string literal is undefined. Of
course, it didn't stop people like James Coplien from putting code
like this in their books (Advance C++ Prog. Styles & Idioms, p. 400):
char *const a = "example 1";
a[8] = '2'; // Coplien says this is OK, but it's actually undefined
c
----------------------------------------------------
| Chad Loder - Somerville, MA, USA |
| EMail: [EMAIL PROTECTED] |
| Home Page: http://www.ccs.neu.edu/home/cloder |
----------------------------------------------------
_______________________________________________
[EMAIL PROTECTED]
http://www.freeamp.org/mailman/listinfo/freeamp-dev