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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T03:10:58+00:00 2026-06-01T03:10:58+00:00

it should set the current character to next character. For example: while( *foo )

  • 0

it should set the current character to next character. For example:

while( *foo ) { 
 if(baa(*foo)) *foo++ = *++foo;
  foo++;
}

But I get the following errors:

error: operation on ‘foo’ may be undefined [-Werror=sequence-point]
cc1: all warnings being treated as errors

Can anyone explain why that? that isn’t valid C syntax?

  • 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-01T03:10:59+00:00Added an answer on June 1, 2026 at 3:10 am

    Let’s take a closer look at this expression:

    *foo++ = *++foo
    

    *foo++ evaluates as *(foo++) (postfix ++ has higher precedence than unary *); you take the current value of foo and dereference it, and advance foo as a side effect. *++foo evaluates as *(++foo) (both unary * and ++ have the same precedence, so they are applied left-to-right); you take the value of foo + 1, dereference the result, and then advance foo again as a side effect. Then you assign the result of the second expression to the first.

    The problem is that the exact order in which all of those side effects are applied (assignment, postincrement, and preincrement) is unspecified; the compiler is free to reorder those operations as it sees fit. Because of this, expressions of the form x++ = ++x will give different results for different compilers, or for the same compiler with different compiler settings, or even based on the surrounding code.

    The language standard explicitly calls this out as undefined behavior so that compiler implementors are free to handle the situation any way they see fit, with no requirement to try and do the “right thing” (whatever the “right thing” may be). GCC obviously issues a diagnostic in this case, but they don’t have to. For one thing, not all cases are so easy to detect as this. Imagine a function like

    void bar (int *a, int *b)
    {
      *a++ = *++b;
    }
    

    Is this a problem? Only if a and b point to the same thing, but if the caller is in a separate translation unit, there’s no way to know that at compile time.

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

Sidebar

Related Questions

I have the following code that seems like it should set my insertParameter but
How should i set a while loop counter? When is it supposed to be
I've got a field on a class that should set the current date correctly:
In theory, this code should set the new lock status to the users and
Application[temp] = 8; should set the value 8 to the key temp . However,
How should I set WordWrap = false to a System.Windows.Forms.Label ? I have a
Is there any penalty, such that you should only set them as nullable when
What does SC_BAD_REQUEST signify? And when should be set statusCode of HttpServletResponse to SC_BAD_REQUEST
What are the requirements of a PE file (PE/COFF)? What fields should be set,
I have the following test: it should respond with a json object do xhr

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.