delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2001/04/18/12:02:45

Date: Wed, 18 Apr 2001 19:04:28 +0300 (IDT)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
X-Sender: eliz AT is
To: djgpp AT delorie DOT com
Subject: Re: MINGW vs DJGPP
In-Reply-To: <3ADDB56A.D939F09@ma.tum.de>
Message-ID: <Pine.SUN.3.91.1010418185938.180B-100000@is>
MIME-Version: 1.0
X-MIME-Autoconverted: from QUOTED-PRINTABLE to 8bit by delorie.com id MAA03073
Reply-To: djgpp AT delorie DOT com
Errors-To: nobody AT delorie DOT com
X-Mailing-List: djgpp AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

On Wed, 18 Apr 2001, Waldemar Schultz wrote:

> more problems with MINGW port of gcc-2.95.2:
> 
> strw.c:
>  #include <stdio.h>
>  #include <stdlib.h>
>  #include <string.h>
> 
>  int main(void)
>  {
>  char *bbb="ABCDefgh";
> 
>   strlwr(bbb);
>   printf("%s\n",bbb);
>   return EXIT_SUCCESS;
>  }
> 
> #66:W98>gcc -c strw.c -g -W -Wall
> #66:W98>gcc strw.o -o strw.exe -mwindows -mconsole
> #66:W98>strw.exe
> STRW verursachte einen Fehler durch eine ungültige Seite [error: invalid
> page]

This is a classic gotcha with GCC.  The bug is in your program: you are 
trying to change a read-only string.

GCC by default puts constant strings into read-only storage, so trying to 
modify it triggers a protection violation.  This will happen on any 
platform; DJGPP avoids this problem because our .data and .text segments 
overlap (due to subtleties of exception handling in DPMI environment), 
and that prevents us from making the code segment write-protected.  MinGW 
doesn't have this problem, so your bug is exposed.

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019