alank2 5 Posted February 23, 2023 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
hansw 4 Posted February 23, 2023 Hi, you must not increment and refer to a variable in one statement. It's undefined behavior, because the result depends on whether AData[ui3++] or AData[ui3] is evaluated first. See https://stackoverflow.com/questions/33743254/c-unsequenced-modification-and-access-to-i Share this post Link to post
Roger Cigol 107 Posted February 23, 2023 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
alank2 5 Posted February 28, 2023 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