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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T04:18:38+00:00 2026-05-16T04:18:38+00:00

A few simple questions. const int gFirst; const int gSecond; struct Data { static

  • 0

A few simple questions.

const int gFirst;
const int gSecond;

struct Data
{
    static int First;
    static int Second;

    int first;
    int second;
};

Data data;

Is it guaranteed that the following statements are true?

  1. &gFirst < &gSecond
  2. &Data::First < &Data::Second
  3. &data.first < &data.second
  • 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-16T04:18:39+00:00Added an answer on May 16, 2026 at 4:18 am

    1) This result is unspecified.
    2) This result is unspecified.*
    3) Yes.

    The relevant section in the standard is §5.9/2. Relational comparisons between the pointers p and q are only specified when:

    • p and q point to the same object or function, point to one past the end of the same array, or both are null. In this case, p <= q and p >= q are true, and p < q and p > q are false.
    • p and q point to nonstatic data members of the same object, the pointer to the later declared member compares greater. (Note, this comparison cannot be between access specifiers.)
    • p and q point to elements within the same array or one past the end of the array, the pointer to the element with the higher subscript or to one past the end of the array compares greater.
    • p and q point to data members of the same union object, in which case they compare equal.

    In all other cases, the result is not specified.

    *Because they are static, they (obviously) do not get the “nonstatic member” rules. They will be defined in some translation unit, and therefore are just like any other pointer. (Unspecified.)


    Note! There is a way to get total ordering, and that is via std::less<void*> (and all the other comparative function objects.)

    This is in §20.3.3/8:

    For templates greater, less, greater_equal, and less_equal, the specializations for any
    pointer type yield a total order, even if the built-in operators <, >, <=, >= do not.

    So while you don’t know if std::less<void*>(&gFirst, &gSecond) is true or false, you are guaranteed:

    std::less<void*>(&gFirst, &gSecond) ==
        std::greater<void*>(&gSecond, &gFirst);
    std::less<void*>(&Data::First, &Data::Second) ==
        std::greater<void*>(&Data::Second, &Data::First);
    

    Which can prove useful.

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

Sidebar

Related Questions

I'm new to .NET and I have few simple questions regarding the GAC. First
I want to build a bot that asks someone a few simple questions and
I have a few simple questions about data storage on a website I am
I am new to TCP programming so here is a few simple questions: Client
I have a few simple scripts that are intended to daisy chain together to
I have written a small makefile for a few simple C programs that compiles
Is there an open-source toolkit out there that has a few simple canvas drawing
I was just viewing stackoverflow page source and I have a few simple questions;
I a few simple questions to make sure I am using properties right in
I've found a few questions on modelling many-to-many relationships, but nothing that helps me

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.