Jump to content
alank2

[bcc64 Warning] a.cpp(1385): unsequenced modification and access to 'ui3'

Recommended Posts

The line of code is this:

 

AData[ui3++]=(AData[ui3]<<4) | (tow_lower(AString[ui1])-'a'+10);

 

I know I am incrementing ui3 in the destination AFTER it is being set.  I am using ui3 in the expression, but it shouldn't be changed until the end.  Why the warning?

Share this post


Link to post

I would really want my compiler to give me a warning if I wrote this line of code. It's not at all clear what you want to happen (and as @hansw  says it is undefined behaviour - although it is likely to be consistent for any one given compiler (my guess only!)). In the interest of good program practice and to help your self write maintainable code please split this into two lines to make it easy to tell what is intended to be achieved.

Share this post


Link to post

I am surprised at this.  Clearly it can't assign a value before it evaluates a value.  I can put the increment on the next line to appease it.

 

Isn't there a definition or design about evaluation order?

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×