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 180631
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T14:37:14+00:00 2026-05-11T14:37:14+00:00

So, as I learned from Michael Burr ‘s comments to this answer , the

  • 0

So, as I learned from Michael Burr‘s comments to this answer, the C standard doesn’t support integer subtraction from pointers past the first element in an array (which I suppose includes any allocated memory).

From section 6.5.6 of the combined C99 + TC1 + TC2 (pdf):

If both the pointer operand and the result point to elements of the same array object, or one past the last element of the array object, the evaluation shall not produce an overflow; otherwise, the behavior is undefined.

I love pointer arithmetic, but this has never been something I’ve worried about before. I’ve always assumed that given:

 int a[1];  int * b = a - 3;  int * c = b + 3; 

That c == a.

So while I believe I’ve done that sort of thing before, and not gotten bitten, it must have been due to the kindness of the various compilers I’ve worked with – that they’ve gone above and beyond what the standards require to make pointer arithmetic work the way I thought it did.

So my question is, how common is that? Are there commonly used compilers that don’t do that kindness for me? Is proper pointer arithmetic beyond the bounds of an array a defacto standard?

  • 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. 2026-05-11T14:37:15+00:00Added an answer on May 11, 2026 at 2:37 pm

    This is not ‘implementation defined’ by the Standard, this is ‘undefined’ by the Standard. Which means that you can’t count on a compiler supporting it, you can’t say, ‘well, this code is safe on compiler X’. By invoking undefined behavior, your program is undefined.

    The practical answer isn’t ‘how (where, when, on what compiler) can I get away with this’; the practical answer is ‘don’t do this’.

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

Sidebar

Ask A Question

Stats

  • Questions 84k
  • Answers 84k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer What you are getting is not a webpage but an… May 11, 2026 at 5:02 pm
  • Editorial Team
    Editorial Team added an answer Take a look at Boost Spirit. May 11, 2026 at 5:02 pm
  • Editorial Team
    Editorial Team added an answer Found the solution to my problem in my second question. May 11, 2026 at 5:02 pm

Related Questions

So, as I learned from Michael Burr 's comments to this answer , the
When coding new javascript heavy websites, which order or web browser do you code
UPDATE: I recently learned from this question that in the entire discussion below, I
I have a NSArray of UIImageViews that I want to loop over and quickly
I've got a bit of a problem. I'm moving my source repository from one

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.