Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6562645
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T13:44:00+00:00 2026-05-25T13:44:00+00:00

According to the Wikipedia (http://en.wikipedia.org/wiki/Buffer_overflow) Programming languages commonly associated with buffer overflows include C

  • 0

According to the Wikipedia (http://en.wikipedia.org/wiki/Buffer_overflow)

Programming languages commonly associated with buffer overflows include C and C++, which provide no built-in protection against accessing or overwriting data in any part of memory and do not automatically check that data written to an array (the built-in buffer type) is within the boundaries of that array. Bounds checking can prevent buffer overflows.

So, why are ‘Bounds Checking’ not implemented in some of the languages like C and C++?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T13:44:01+00:00Added an answer on May 25, 2026 at 1:44 pm

    Basically, it’s because it means every time you change an index, you have to do an if statement.

    Let’s consider a simple C for loop:

    int ary[X] = {...};  // Purposefully leaving size and initializer unknown
    
    for(int ix=0; ix< 23; ix++){
        printf("ary[%d]=%d\n", ix, ary[ix]);
    }
    

    if we have bounds checking, the generated code for ary[ix] has to be something like

    LOOP:
        INC IX          ; add `1 to ix
        CMP IX, 23      ; while test
        CMP IX, X       ; compare IX and X
        JGE ERROR       ; if IX >= X jump to ERROR
        LD  R1, IX      ; put the value of IX into register 1
        LD  R2, ARY+IX  ; put the array value in R2
        LA  R3, Str42   ; STR42 is the format string
        JSR PRINTF      ; now we call the printf routine
        J   LOOP        ; go back to the top of the loop
    
    ;;; somewhere else in the code
    ERROR:
        HCF             ; halt and catch fire
    

    If we don’t have that bounds check, then we can write instead:

        LD R1, IX
    LOOP:
        CMP IX, 23
        JGE END
        LD R2, ARY+R1
        JSR PRINTF
        INC R1
        J   LOOP
    

    This saves 3-4 instructions in the loop, which (especially in the old days) meant a lot.

    In fact, in the PDP-11 machines, it was even better, because there was something called “auto-increment addressing”. On a PDP, all of the register stuff etc turned into something like

    CZ  -(IX), END    ; compare IX to zero, then decrement; jump to END if zero
    

    (And anyone who happens to remember the PDP better than I do, don’t give me trouble about the precise syntax etc; you’re an old fart like me, you know how these things slip away.)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

According to http://en.wikipedia.org/wiki/Heap_%28data_structure%29#Comparison_of_theoretic_bounds_for_variants , it takes Θ(logn) (which translates to O(logn)) to perform the
According to wikipedia! http://en.wikipedia.org/wiki/ORDBMS IBM's DB2, Oracle database, and Microsoft SQL Server, make claims
I'm working on coloring a map according to the four-color theorem ( http://en.wikipedia.org/wiki/Four_color_theorem )
I am new to python and graphics but have programmed before. According to http://en.wikipedia.org/wiki/Transformation_matrix#Rotation
According to wiki http://en.wikipedia.org/wiki/Extensible_Messaging_and_Presence_Protocol , xmpp is using http binding (rather an http pooling)
According to http://en.wikipedia.org/wiki/CUDA , Maximum x- or y-dimension of a block 1024 Maximum z-dimension
According to http://en.wikipedia.org/wiki/Fold_(higher-order_function ), a right fold can operate on infinite lists if the
According to Wikipedia, on the Comparison of programming languages page, it says that F#
I was reading this: http://en.wikipedia.org/wiki/Thread_safety Is the following function thread-safe? void foo(int y){ int
I have simple WebView code like this: WebView wv = (WebView) findViewById(R.id.webview1); wv.loadUrl(http://en.wikipedia.org/wiki/Book); But

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.