Warning[Pa082]: undefined behavior: the order of volatile accesses is undefined in this statement

Warning[Pa082]: undefined behavior: the order of volatile accesses is undefined in this statement EW targets: All EW component: C/C++ compiler Keywords: C code, keywords, SFR, UART Last update: January 14, 2009 Background The warning [Pa082] is issued if 2 (or more) of the variables in a C-statment are volatile. The message text “…order of volatile accesses is undefined…” is the central information, i.e. the compiler (following the ANSII standard) can access the variables in an order that is not defined. Is this a problem , or not… …well that depends on your application. Volatile is (typically) used for variables that are accessed from several threads in the application, and for Special Function Register that are the connection in/out of the chip. So you must study the volatile variables that are present in this C-statement and from the usage of these volatile variables decide if you must make a change or not. How to change The change is to break up the C-statement, so that each new C-statement holds only one access to a volatile variable. In this small example the variables internalChannelSelect and ADC are volatile. If so the following C-source will issue the “Warning[Pa082]”. intAnalogSample[internalChannelSelect] = ADC[internalChannelSelect] ; Then the following change will make the C-source predictable. i = internalChannelSelect; k = ADC; intAnalogSample = k;

分享到: 更多
版权申明:

本站保留所有原创文章的版权,本站地址:奔跑的博客[http://www.elecbench.com]

原创文章转载时请注明出处,并添加文章所在页面的链接:http://www.elecbench.com/warningpa082-undefined-behavior-the-order-of-volatile-accesses-is-undefined-in-this-statement/

本站所有 2010年3月4日 以后发表、未标明为“转载”的文章均是本站原创。

发表评论


(设置自己的个性头像)

*

申请属于你的免费顶级域名