GIDForums  

Go Back   GIDForums > Computer Programming Forums > C++ Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 03-Feb-2008, 12:52
MKQ MKQ is offline
New Member
 
Join Date: Jan 2008
Posts: 3
MKQ is on a distinguished road
Question

Problem relating to Arrays


Hello everyone,

Can over running of array lead to the catastrophic failures? The answer to this is may be YES I think.

Then why does not C++ provide bound checking on array operations and who is responsible to prevent array overruns?
  #2  
Old 03-Feb-2008, 14:39
davekw7x davekw7x is offline
Outstanding Member
 
Join Date: Feb 2004
Location: Left Coast, USA
Posts: 5,218
davekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to behold

Re: Problem relating to Arrays


Quote:
Originally Posted by MKQ
Can over running of array lead to the catastrophic failures ?
If by "catastrophic failures" you mean something like program crashing or programs giving wrong answers or programs doing just about anything, then the answer is, indeed, "yes." The technical term is "undefined behavior."
Quote:
Originally Posted by MKQ

Then why...

I believe that the designer of the language wanted a simple powerful language (somewhat higher-level than assembly language, but still simple) that could be used to write operating systems. The run-time overhead of checking for out-of-bounds array references (or any other kind of reference to invalid memory addresses) was considered too expensive in terms of program CPU usage (running time) and memory use efficiency. Therefore, such niceties were not built into the language.

(Maybe someone else has some more meaningful insight into this. I would be interested in other opinions.)

The program designer and coder is (are) responsible for implementing programs that can not indulge in undefined behavior.

Regards,

Dave
  #3  
Old 05-Feb-2008, 10:02
TurboPT's Avatar
TurboPT TurboPT is online now
Senior Member
 
Join Date: Feb 2006
Location: Atlanta, GA
Posts: 1,140
TurboPT is a jewel in the roughTurboPT is a jewel in the roughTurboPT is a jewel in the rough

Re: Problem relating to Arrays


Quote:
Originally Posted by MKQ
Then why does not C++ provide bound checking on array operations...
Dave is correct: See the 2nd bulleted item (the short response -- basically what dave said) here. (a FAQ response by the creator of C++ [Stroustrup])
__________________
Use the force...read the source!!
WYCIWYG -- what you code is what you get!
 
 

Recent GIDBlogProgramming ebook direct download available by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Runtime Problem involving "printf" in C Program supamakia C Programming Language 2 09-Oct-2005 11:09
C++ Syntax Problem (Arrays and Loops) rpgaction C++ Forum 5 01-Sep-2005 03:25
a significant problem after installing Xp mohammad Computer Software Forum - Windows 10 09-Aug-2005 08:03
Noob question on c arrays and functions brett C Programming Language 1 20-Apr-2005 04:59
problem with arrays melas C Programming Language 5 12-Oct-2004 05:18

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 20:37.


vBulletin, Copyright © 2000 - 2009, Jelsoft Enterprises Ltd.