473,503 Members | 2,114 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Bound checking in array

14 New Member
Can over running of array lead to the catastrophic failures? If ‘Yes’ then why does not C++ provide bound checking on array operations and who is responsible to prevent array overruns?

plz explain in detail...
Feb 3 '08 #1
5 3020
esrever
10 New Member
Can over running of array lead to the catastrophic failures? If ‘Yes’ then why does not C++ provide bound checking on array operations and who is responsible to prevent array overruns?

plz explain in detail...
Yes it can be catastrophic, since you access memory you're not supposed to. For example another object might reside after the end of your array, and by writing after the end of your array, you 'silently' alter the other object.

One reason that does not provide bounds checking is speed, if you want checking, either make a class for it or use std::vector<>

You are responsible to prevent the overruns..
Feb 3 '08 #2
luckyyyyyy
14 New Member
Yes it can be catastrophic, since you access memory you're not supposed to. For example another object might reside after the end of your array, and by writing after the end of your array, you 'silently' alter the other object.

One reason that does not provide bounds checking is speed, if you want checking, either make a class for it or use std::vector<>

You are responsible to prevent the overruns..

do you mean programmers are responsible......
Feb 3 '08 #3
JosAH
11,448 Recognized Expert MVP
do you mean programmers are responsible......
Yep, that's what they mean; btw are you also Naseer Ahmad?

kind regards,

Jos (mod)
Feb 3 '08 #4
weaknessforcats
9,208 Recognized Expert Moderator Expert
It could happen that overrunning the array bound is exactly what your program requires in some bizarre situation. If C++ disallowed that, then you couldn't use C++ for that application and that would violate the C++ Prime Directive: There is NO programming situation that cannot be handled by C++.
Feb 3 '08 #5
luckyyyyyy
14 New Member
It could happen that overrunning the array bound is exactly what your program requires in some bizarre situation. If C++ disallowed that, then you couldn't use C++ for that application and that would violate the C++ Prime Directive: There is NO programming situation that cannot be handled by C++.
thanks guys............................................
Feb 4 '08 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

19
4065
by: James Fortune | last post by:
I have a lot of respect for David Fenton and Allen Browne, but I don't understand why people who know how to write code to completely replace a front end do not write something that will automate...
6
3654
by: Flip | last post by:
I'm reading the O'Reilly's Progamming C# book and I have a question about array bounds checking. On page 174, near the top, they show an example where c# does indeed to array bounds checking cause...
4
2201
by: bienwell | last post by:
Hi all, Data displayed on the datalist control is bound by the column name of the dataset like this : <%# DataBinder.Eval(Container.DataItem, "title")%> Could I use an element of the array...
4
2243
by: Mark Gibson | last post by:
Hi, I've been playing about with array's, and found the concat operator '||' quite useful, apart from the fact that prepending an element places it in a lower subscript. Is there a way of...
13
2501
by: venkatesh | last post by:
hai I need to know about array out of bound error which is thought by our lecturer .she thought that when u gross the intialially specified size it will show that error,but when I am working on...
24
1934
by: Kavya | last post by:
int main (){ int a={{1,2,3},{4,5,6}}; int (*ptr)=a; /* This should be fine and give 3 as output*/ printf("%d\n",(*ptr)); ++ptr;
2
3099
by: Gianluca | last post by:
If you create an array using Array.CreateInstance() and use a lower bound > 0, you apparently get an array of the wrong type. int lenghts = new int {1}; int lowerBounds = new int {1}; string ar...
3
9089
by: Jerry West | last post by:
I'd like to get the upper bound index of an integer array. I've tried the following: Dim i as Integer Dim arrayIng() as Integer i = arrayIng.GetUpperBound This doesn't work. It seems...
1
1243
by: Latha | last post by:
I have bound a array of objects to datagridview in vb.net. If I add new objects to array, that doesn't reflect in datagridview. What I have to do? Thanks, Latha.P
0
7205
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7093
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7287
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7348
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
5592
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5021
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4685
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3166
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
397
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.