473,657 Members | 2,678 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 3029
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
4091
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 the code that implements managing unbound controls on forms given the superior performance of unbound controls in a client/server environment. I can easily understand a newbie using bound controls or someone with a tight deadline. I guess I need...
6
3664
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 the example shows a System.IndexOutOfRangeException being thrown. However, in the very next section (Jagged arrays) they have warning section that says "Java programmers take note: While Java does bounds checking on array use, C# does not." ...
4
2205
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 (i.e. index=0) which has the name "title" in place of it ? For example:
4
2257
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 either: a) prepending an element, but shifting existing elements up a subscript, so that the lower bound remains the same? eg: 1 ||> ARRAY -- new operator ||> shift array and prepend
13
2519
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 my computer it shows only the value which is allocated after the declaration?
24
1946
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
3115
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 = (string)Array.CreateInstance(typeof(string), lengths, lowerBounds); Throws an InvalidCastException because "string" cannot be casted to "string".
3
9100
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 GetUpperBound behaves more like a function in that it wants a passed parameter. Is there not a property similar to VB6
1
1247
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
8316
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8737
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8610
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7345
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5636
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4168
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4327
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1967
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1730
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.