delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2005/10/20/09:45:25

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
Message-ID: <20051020134511.1989.qmail@web30015.mail.mud.yahoo.com>
Date: Thu, 20 Oct 2005 06:45:11 -0700 (PDT)
From: community help <helpcomm AT yahoo DOT com>
Subject: Re: problem with g++ on cygwin
To: Eric Blake <ebb9 AT byu DOT net>
Cc: cygwin AT cygwin DOT com
In-Reply-To: <43579BEF.9010704@byu.net>
MIME-Version: 1.0
X-IsSubscribed: yes

Hi,

I'm sorry. After your answer i realised that my
message should be posted on a c/c++ mailing list not
in this one.

Sorry again

--- Eric Blake <ebb9 AT byu DOT net> wrote:

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> According to community help on 10/20/2005 7:06 AM:
> > Hi,
> > 
> > I'm using g++ on cygwin for developping some c++
> > programs.
> > 
> > I noticed that everytime i manipulate pointers i
> have
> > an error saying:
> > "Segmentation Fault <Core Dumped>".
> 
> Well, it's because you are trying to modify
> read-only memory.  Fix the bug
> in your code.  Your problem is not cygwin-specific,
> although cygwin is a
> little less forgiving of memory usage errors, and
> more likely to core dump
> when your code is buggy.
> 
> > ----------------------
> > #include <iostream.h>
> > #include <string.h>
> > 
> > int main()
> > {
> > 	char * str;
> > 	str = "hello";
> 
> The type of "hello" is const char*, because it lives
> in read-only memory.
>  You are (silently) casting away the const, and that
> is your bug; compile
> with -Wall and you should be getting a warning.
> 
> > 	*(str+1) = 'a';
> 
> Oops - now you are trying to change a read-only
> location.
> 
> Now, had you declared this instead:
> char str[] = "hello";
> 
> Then *(str+1) = 'a' is legal, because C++ allows a
> char[] initializer to
> copy the contents of a string literal, without
> putting it in read-only memory.
> 
> - --
> Life is short - so eat dessert first!
> 
> Eric Blake             ebb9 AT byu DOT net
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.1 (Cygwin)
> Comment: Public key at
> home.comcast.net/~ericblake/eblake.gpg
> Comment: Using GnuPG with Thunderbird -
> http://enigmail.mozdev.org
> 
>
iD8DBQFDV5vv84KuGfSFAYARAg+yAJwIbqTkFDH5j9+a3Mmn2ON7KL8rwgCfTALA
> v2bKNT8djHRvcVBHSSuFQ7g=
> =/+gu
> -----END PGP SIGNATURE-----
> 
> --
> Unsubscribe info:     
> http://cygwin.com/ml/#unsubscribe-simple
> Problem reports:      
> http://cygwin.com/problems.html
> Documentation:         http://cygwin.com/docs.html
> FAQ:                   http://cygwin.com/faq/
> 
> 



		
__________________________________ 
Yahoo! Music Unlimited 
Access over 1 million songs. Try it free.
http://music.yahoo.com/unlimited/

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

- Raw text -


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