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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T12:10:31+00:00 2026-06-10T12:10:31+00:00

In c99, my understanding is that comparing two pointers which do not point within

  • 0

In c99, my understanding is that comparing two pointers which do not point within the same aggregate results in undefined behavior. Given an aggregate A, a pointer p_good which is known to point within A, and a pointer p_unknown which may or may not point within A, is it possible to construct a portable test with defined behavior which determines whether it is safe to compare p_good and p_unknown?

Obviously, this test cannot itself fall afoul of the restrictions on comparing pointers.

I suspect that the answer is ‘no’, but I’d be happy to be shown otherwise.

  • 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-06-10T12:10:32+00:00Added an answer on June 10, 2026 at 12:10 pm

    You commented:

    Another way to frame the question would be like this: Given the definition of an aggregate ‘A’ and a pointer p, is it possible to answer the question ‘does p point within A’ without violating the rule on inequality testing of pointers to different aggregates

    The only way I can interpret this meaningfully is that you either have an object of type Aggregate type or a pointer to one. Then the answer is simple:

    Pseudo-code:

    bool p_in_A = false;
    for (each element in Aggregate A)
        if (&element == p)
            p_in_A = true;
    

    There is no way to tell whether a stray pointer belongs to an unknown aggregate object (or points to “between” elements in an aggregate).

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

Sidebar

Related Questions

I just read that C99 has double_t which should be at least as wide
I believe that in C99, modification of string literals is undefined behaviour. I don't
I have a c99 function that uses openmp, which works as expected. I also
In C99, equality == does not seem ever to be undefined. It can produce
How universally is the C99 standard supported in today's compilers? I understand that not
I use only C99, and, yesterday, I heard that it was impossible to mix
The C99 Standard says in $6.5.2. Between the previous and next sequence point an
I was looking at new features of C99 and saw the floating point environment:
What you can't do in C (C99 standard) that you can do in Objective-C?
In C99, I include stdint.h and that gives me UINT32_MAX as well as uint32_t

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.