On Mon, 29 Sep 2003 10:15:56 +0530, "Vijay Kumar R Zanvar"
<vi*****@hotmail.com> wrote in comp.lang.c:
Hi,
I have following 2 questions:
* What is bus error?
* How is it different from segmentation fault?
Thanks
--------------------------------------------------------------
Please use a proper signature separator in the future. As defined by
Internet RFCs, a proper signature separator is like mine, below. It
consists of a line containing exactly two hyphen characters followed
by a single blank space "-- ". It is not a matter of style but of
using the standard format that existing newsreaders recognize.
As for your question, the C standard does not define either "bus
error" or "segmentation fault", these are things that happen with your
particular compiler on your particular operating system.
In general, they are both the result of something wrong in your
program, an error that produces undefined behavior. When your program
generates undefined behavior C no longer specifies what might happen,
and things like "bus error" and "segmentation faults" are the results
of certain types of undefined behavior on your particular system.
To find out for sure you need to ask in a group that supports your
particular compiler/OS combination.
For several common such combinations, a segmentation fault results
when your program tries to access memory that does not belong to it,
for example with an uninitialized or null pointer, or writes past the
end of allocated memory. Bus faults generally result when you play
games with pointer conversions and access a variable using a pointer
with incorrect alignment.
--
Jack Klein
Home:
http://JK-Technology.Com
FAQs for
comp.lang.c
http://www.eskimo.com/~scs/C-faq/top.html
comp.lang.c++
http://www.parashift.com/c++-faq-lite/
alt.comp.lang.learn.c-c++
ftp://snurse-l.org/pub/acllc-c++/faq