Showing results for 
Search instead for 
Did you mean: 

CVI 2013 compiler: increment / decrement operator evaluation

Go to solution

I'm looking at pulling an old project forward to CVI 2013, but have hit a challenge, which is documented as follows:


"In assignment, the value of the right operand is evaluated before an array indexing is performed in the left operand. Expressions such as a[i] = i++; will evaluate differently in LabWindows/CVI 2013 when compared with previous versions."


(There is a somewhat related thread here to do with the order that function arguments are evaluated.)


This change in evaluation order is shocking to me. I assume there is some C history behind it, and I'm not going to be able to change that.


So, my question is: What is the easiest way to find all places in my code where this could affect me? I have ~75,000 lines of legacy code. Perhaps some regex magic?




0 Kudos
Message 1 of 8

You can try to compile your code with sequence point checking. CVI compiler doesnot seems to know that.

But maybe lastest version of clang and/or gcc can help there. Be sure to compile with and without optimization, some warning messages depend on this.

( try -Wsequence-point on cmd line or  something like #pragma clang diagnostic warning "-Wsequence-point" in source code)


Better but harder(i think) sollution can be to use some MISRA-C checker, they should detect this but maybe they give you too much warnings about all the unspecified and undefined behaviours.

Some list is on (section analyzers):

I do not use any of them so i cannot reccomend one.

Message 2 of 8

Thanks! That site also has more info on this particular issue here. It looks like there are some detection tools available, listed nearer the bottom of that page.  I have other tasks taking higher priority right now, but it is good to know there is hope for a non-manual option.



0 Kudos
Message 3 of 8
Accepted by topic author Ian.W


I am glad to help.

I  test the last version of clang (3.7 builded from SVN), and i can confirm, that it detect this "issue" as warning(and lot of other warnings too).

Also it can be seamlessly integrated to CVI IDE as external compiler, so it is easy to switch between CVI regular compiler and this one. I can write some small "guide" later, If you are interested.


Message 4 of 8

I would be very glad to see this guide, actually.

I was hoping to have clang updated in CVI but since nobody knows if or when this will happen I'd also like to try using a newer clang as external compiler.


Thanks a lot!!

0 Kudos
Message 5 of 8

Thank you, OVR_CZ !  I'll echo Wolfgang here: Any tips or guidance you get a chance to write would be much appreciated.



0 Kudos
Message 6 of 8

I wrote something like "how-to" from my notes.

It is rather big, and my english is not so good, so i choose to publish it in wiki-like document there:  feel free to comment and/or edit them.


Message 7 of 8

CVI 2015 adds the warning flag -Wsequence-point in Common level.

Message 8 of 8