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

  • Home
  • SEARCH
  • 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 3451560
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T09:09:30+00:00 2026-05-18T09:09:30+00:00

I have started studying about C++0x. I came across the follow expression somewhere: int

  • 0

I have started studying about C++0x. I came across the follow expression somewhere:

int l = 1, m=2;
++l *= m;

I have no idea whether the second expression has well defined behavior or not. So I am asking it here.

Isn’t it UB? I am just eager to know.

  • 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-18T09:09:30+00:00Added an answer on May 18, 2026 at 9:09 am

    In the code above, prefix ++ has precedence over *=, and so gets executed first. The result is that l equals 4.

    UPDATE: It is indeed undefined behavior. My assumption that precedence ruled was false.

    The reason is that l is both an lvalue and rvalue in *=, and also in ++. These two operations are not sequenced. Hence l is written (and read) twice “without a sequence point” (old standard wording), and behavior is undefined.

    As a sidenote, I presume your question stems from changes regarding sequence points in C++0x. C++0x has changed wording regarding “sequence points” to “sequenced before”, to make the standard clearer. To my knowledge, this does not change the behavior of C++.

    UPDATE 2: It turns out there actually is a well defined sequencing as per sections 5.17(1), 5.17(7) and 5.3.2(1) of the N3126 draft for C++0x. @Johannes Schaub’s answer is correct, and documents the sequencing of the statement. Credit should of course go to his answer.

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

Sidebar

Related Questions

I just started studying programming about 6 months ago and I have really been
I have recently started studying Google Web Toolkit. I have went through some walkthroughs,
I have started studying data structures again . I found very few practical uses
I have just started studying Python . I am referring to the tutorials at
I have just started studying Android and I am still lost. I would just
I have just started studying Android, I have limited java knowledge but am semi
I have just started studying Objective - C..and I encountered a problem which I
I've (very) recently started studying about Prism (for a WPF app) and I've been
I have just started self-studying the Dragon book of Compiler Design. I am working
I have started development of an app which is data reliant. It has a

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.