public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
From: "Dikandé Alain Moïse" <dikande@hermes.usherb.ca>
To: Daniel Bolgheroni <dab__@uol.com.br>
Cc: gcc-help@gcc.gnu.org
Subject: Re: Segmentation fault Causes
Date: Tue, 22 Apr 2003 18:24:00 -0000	[thread overview]
Message-ID: <1051035877.3ea588e50a611@imp.usherb.ca> (raw)
In-Reply-To: <20030224045442.GA25932@uol.com.br>

.. Most of core dumping signals indicate bad pointer adresses to your outputs/inputs. Check that your program is not trying to access a memory location 
outside its address.  Bad use of pointers cause bus errors and segmentation violations are typically
out-of-bounds array references, and/or references through uninitialized or
mangled pointers.  Look very closely in your program for bizarre things like
that.  A frequent example of bad use of pointers adress in C is:

        int b;
        scanf("%d", b);

When compiled, you will have the "segmentation fault" signal. Instead, with the correct version:

        int c;
        scanf("%d", &c);

No "segmentation fault message(core file) is given(generated). 

In  C++, a typical example is:

        int* q=new int[150];
        cout<< q[100];

instead of the correct version:

        int* Q=new int[200];
        cout << Q[199]

Good Kuck..

En réponse à Daniel Bolgheroni <dab__@uol.com.br>:

> What are the causes that a program can give an error "Segmentation fault
> (core dumped)"?
> 
> I'm compiling a program I'm writing but I getting some of this error
> messages executing it. I looked into gcc FAQ and gcc 2.95 manual, but I
> found no references to this problem.
> 
> I'm using the following version of gcc:
> 
> gcc version 2.95.3 20010315 (release) (NetBSD nb3)
> 
> Thank you.
> 
> 
> 



                      DIKANDÉ ALAIN MOÏSE
Present: CERPEMA, Département de Physique, fac. Sciences, Univ. Sherbrooke J1k-2R1 
Québec, Canada. tel: (819)821-8000 ext. 3043.
Permanent: Département de Physique, Faculté des Sciences, Université de Douala BP 24157 Douala, Cameroun.

"Le mépris des autres et des choses, plutôt que nous grandir, nous rabaisse et 
met en péril notre capacité de compréhension du monde et de l' humanité". 
Albert Einstein.

  parent reply	other threads:[~2003-04-22 18:24 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-02-24  5:07 Daniel Bolgheroni
2003-02-24  5:22 ` J.C.Wren
2003-04-22  1:02 ` Daniel Bolgheroni
2003-04-22  7:47 ` bjorn rohde jensen
2003-04-22 18:24 ` Dikandé Alain Moïse [this message]
2003-05-24 11:07 ` RedHat 8.0 `istream_iterator' undeclared (first use this function) MR
2003-05-24 12:21   ` Oscar Fuentes
2003-05-24 12:50   ` LLeweLLyn Reese
2003-02-24  5:39 Segmentation fault Causes Ajay Bansal
2003-02-24  8:00 ` Sergei

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1051035877.3ea588e50a611@imp.usherb.ca \
    --to=dikande@hermes.usherb.ca \
    --cc=dab__@uol.com.br \
    --cc=gcc-help@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).