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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T09:37:14+00:00 2026-06-13T09:37:14+00:00

struct BLA { int size_; int size()const{ return size_; } } int x; BLA

  • 0
struct BLA
{
    int size_;

    int size()const{ return size_; }
}

int x;
BLA b[ 2 ];
BLA * p = &b[ 0 ];

b[ 0 ].size_ = 4;
b[ 1 ].size_ = 6;

When I compile this line:

x = p->size_ + (p++)->size_;

I receive the expected result. But, when I compile this line (without the previous one):

x = p->size() + (p++)->size();

Then I get different result. The ‘p’ is not incremented at the same time as in the previous line. Can someone explain this, please? Tried on VS 2008 and VS 2010.

  • 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-13T09:37:15+00:00Added an answer on June 13, 2026 at 9:37 am

    It’s undefined behaviour to seperately read and modify a variable without an intervening sequence point. You’ve seen a good example of the consequences of that.

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

Sidebar

Related Questions

struct X{}; template<class T> decltype(X() == int()) f(T const&){ return true; } int main(void)
struct that { that &frob() { return *this; } that frob() const { return
struct Foo { int data; Foo() = default; Foo(const Foo& arg) = default; };
struct Set { int a; Set() : a(30){}; bool operator>( const Set& ref )
struct result { int number; int length; }; struct result findLongestSeq(int intarray[], int size)
struct Foo{ int _a; this(int a){ _a = a; } int opCall(int b){ return
struct Div { int i; int j; }; class A { public: A(); Div&
Simple, I have a struct like this: struct bla{ string name; float depth; }
struct A { static const int a = 5; struct B { static const
struct fraction { int num; int denum; } pi; pi.num=22; pi.denum=7; ((fraction*)&(pi.denum))->num=12; cout <<

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.