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

Ask A Question

Stats

  • Questions 499k
  • Answers 499k
  • 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 Check that the assembly referenced in the Web Application matches… May 16, 2026 at 12:43 pm
  • Editorial Team
    Editorial Team added an answer First, you really shouldn't store 3 GB files in SVN.… May 16, 2026 at 12:43 pm
  • Editorial Team
    Editorial Team added an answer Try using NChar instead of Char: SELECT NCHAR(193) May 16, 2026 at 12:43 pm

Trending Tags

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

Top Members

Related Questions

On SO, there are quite a few questions about performance profiling, but I don't
I've written a simple control which basically displays a few words with an image
I found that handy opencv library and tried to program a simple imagemodifier with
I have a few questions regarding stored procedures. After hours of googling, I really
I am starting a simple .NET project with FluentNhibernate . I've followed few examples
I'm preparing for an interview in a few weeks and I thougth I would
I know that this won't directly invert a colour, it will just 'oppose' it.
I have a weird problem. I have a vector that I would like to
This simple program starts with 15 threads - according to the count. Sometimes during
I am designing a simple web-based application. I am new to this web-based domain.I

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.