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

Related Questions

I learned from books that you should write for loop like this: for(var i=0,
I just learned from Peter Lawreys post that this is valid expression, and evaluates
I learned from android dev tutorial and now I can make ListView. and it
I am using Code::blocks to compile my first multiple source file, learned from C
I have a winforms app that installs other apps in a loop. This works
first post. So first off, thanks for all the help over the years as
I have my application frontend developed in Flex 3. For logging, we are using
I'm trying to use the Chilkat encryption library in SQL Server 2008 via a
I have an Android MediaPlayer running that I want to pause when the speech
Below is an example of source I want to use on a machine running

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.