Jun 7, 2010 at 8:25pm UTC
what all errors is possible if u write past the array bounds??
This is one of the interview questions which i thought could bring to a discussion here.
Only possible one I can think of is
segmentation fault in case of gcc compiler while it is access violation exception in case of the visual studio.!
Is there an errors possible apart from this?
Jun 7, 2010 at 8:31pm UTC
When accessing beyond array boundaries, you are verging into the "undefined behavior" section of the C++
standard, and at that point anything is possible.
Jun 8, 2010 at 1:50pm UTC
well, sometimes nothing happens :)
and make them explain why that is the case...
Last edited on Jun 8, 2010 at 1:57pm UTC
Jun 8, 2010 at 2:46pm UTC
nothing is one of the possible things that can happen when I say anything is possible.
Jun 9, 2010 at 3:29am UTC
Guys.. Well.. Anything is possible is agreed.. But what are all the errors you have come across from ur experience..
Jun 9, 2010 at 12:43pm UTC
Buffer overruns (aka writing beyond array bounds) are one of the main ways virus writers can execute rogue
code on your machine.
Segmentation faults, bus errors, variables getting trashed, all kinds of weird stuff that are too numerous to
even begin listing.