<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Variable &amp;quot;sec_mode&amp;quot; is used uninitialized at this location in the sourcecode</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/77453/variable-sec_mode-is-used-uninitialized-at-this-location-in-the-sourcecode</link><description>With IAR (EWARM) 8.50.9 the UART project in the SDK compiles fine. 
 After upgrading to IAR (EWARM) 9.10.1 or 9.10.2 I get compiler error: 
 Error[Go029]: Variable &amp;quot;sec_mode&amp;quot; is used uninitialized at this location in the sourcecode. D:\2\IAR\nRF5_SDK_17</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 19 Jul 2021 20:31:38 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/77453/variable-sec_mode-is-used-uninitialized-at-this-location-in-the-sourcecode" /><item><title>RE: Variable "sec_mode" is used uninitialized at this location in the sourcecode</title><link>https://devzone.nordicsemi.com/thread/320781?ContentTypeID=1</link><pubDate>Mon, 19 Jul 2021 20:31:38 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4838bc1a-8d41-4064-a6e6-2d2e1cb31421</guid><dc:creator>Karl Ylvisaker</dc:creator><description>&lt;p&gt;Hello again Ori,&lt;/p&gt;
[quote user="Renix"]&lt;p&gt;This the fix from IAR&lt;/p&gt;
&lt;p&gt;This is a bug in EWARM 9.10.2.&lt;/p&gt;[/quote]
&lt;p&gt;Thank you for reaching out to IAR about this, and for forwarding me their reply on the matter.&lt;br /&gt;This is very helpful for me to have seen.&lt;/p&gt;
[quote user="Renix"]I tried it and it works.[/quote]
&lt;p&gt;I am happy to hear that they provided a workaround that has resolved the issue you were facing.&lt;/p&gt;
[quote user="Renix"]All the best,[/quote]
&lt;p&gt;And to you as well! :)&amp;nbsp;&lt;br /&gt;&lt;br /&gt;Please do not hesitate to open another ticket if you encounter any issues or questions in the future.&lt;br /&gt;&lt;br /&gt;Good luck with your development!&lt;br /&gt;&lt;br /&gt;Best regards,&lt;br /&gt;Karl&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Variable "sec_mode" is used uninitialized at this location in the sourcecode</title><link>https://devzone.nordicsemi.com/thread/320542?ContentTypeID=1</link><pubDate>Sat, 17 Jul 2021 15:40:34 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:301f9ad3-10dc-4395-80bc-85f767fc1721</guid><dc:creator>Renix</dc:creator><description>&lt;p&gt;Karl,&lt;/p&gt;
&lt;p&gt;This the fix from IAR&lt;/p&gt;
&lt;p&gt;This is a bug in EWARM 9.10.2.&lt;br /&gt; &lt;br /&gt; 1. It was reported as bug&amp;nbsp;EWARM-8754.It has been fixed but not incorporated into&lt;br /&gt; any release yet. Than it was reported again as bug EWARM-8834&amp;nbsp;in NordicSemi nRF5_SDK.&lt;br /&gt; &lt;br /&gt; 2. The Work around is to initilaize the variable in the&amp;nbsp; gap_params_init(void) function&lt;br /&gt; as below:&lt;br /&gt; &lt;br /&gt; static void gap_params_init(void)&lt;br /&gt; {&lt;br /&gt; &amp;nbsp; &amp;nbsp; uint32_t &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;err_code;&lt;br /&gt; &amp;nbsp; &amp;nbsp; ble_gap_conn_params_t &amp;nbsp; gap_conn_params;&lt;br /&gt; &amp;nbsp; &amp;nbsp; ble_gap_conn_sec_mode_t sec_mode = {0};&lt;br /&gt; &lt;br /&gt; I tried it and it works.&lt;br /&gt; &lt;br /&gt; 3. Another work around is to disable the error with #Pragma as below:&lt;br /&gt; &lt;br /&gt; ble_gap_conn_sec_mode_t sec_mode;&lt;br /&gt; #pragma&amp;nbsp;diag_suppress=Go029&lt;br /&gt; BLE_GAP_CONN_SEC_MODE_SET_OPEN(&amp;amp;sec_mode);&lt;br /&gt; &lt;br /&gt; I hope this help.&lt;br /&gt; *****************************************************************************************&lt;br /&gt; The Error explanation:&lt;br /&gt; &lt;br /&gt; The problem is with struct variables with bifields:&lt;br /&gt; If the struct variable as a whole is uninitialized, then you incorrectly get Go029 when setting the first bifield.&lt;br /&gt; &lt;br /&gt; ble_gap_conn_sec_mode_t sec_mode;&lt;br /&gt; BLE_GAP_CONN_SEC_MODE_SET_OPEN(&amp;amp;sec_mode); // Error[Go029]: Variable &amp;quot;sec_mode&amp;quot; is used uninitialized&lt;br /&gt; &lt;br /&gt; *********************************************************************************************&lt;br /&gt; All the best,&lt;br /&gt; /Ori.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Variable "sec_mode" is used uninitialized at this location in the sourcecode</title><link>https://devzone.nordicsemi.com/thread/320454?ContentTypeID=1</link><pubDate>Fri, 16 Jul 2021 13:37:28 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ed4ed27f-e481-426e-9a7e-849358c62dbb</guid><dc:creator>Karl Ylvisaker</dc:creator><description>&lt;p&gt;Hello again,&lt;/p&gt;
[quote user="Renix"]This is what IAR is saying..[/quote]
&lt;p&gt;Thank you for informing me!&lt;/p&gt;
[quote user="Renix"]2. There are several differences between the 2 releases. The major difference related to your case&lt;br /&gt; is that&amp;nbsp; 9.10.2 don&amp;#39;t support any Misra98 or Misra 2004 as 8.50.9.[/quote][quote user="Renix"]4. None of these changes explain the error since my understanding is Misra C 98/04 are disabled in your 8.50.9[/quote]
&lt;p&gt;Could it be that the type of variable declaration (populating it through the macro) if not recognized by the IAR compiler anymore, if it originally came from the now unsupported MISRA C standards?&lt;br /&gt;I think something like this might be the case.&lt;/p&gt;
[quote user="Renix"]I will send all this information to IAR back office and wait for thier response.[/quote]
&lt;p&gt;I look forward to hearing their response on this! :)&lt;br /&gt;&lt;br /&gt;Best regards,&lt;br /&gt;Karl&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Variable "sec_mode" is used uninitialized at this location in the sourcecode</title><link>https://devzone.nordicsemi.com/thread/320432?ContentTypeID=1</link><pubDate>Fri, 16 Jul 2021 12:52:52 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:18e4b5e6-a895-4d67-8143-07dac141a7f3</guid><dc:creator>Renix</dc:creator><description>&lt;p&gt;Karl,&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;This is what IAR is saying..&lt;/p&gt;
&lt;p&gt;1. Please see the 2 .ewp files for 8.50.9 and 9.10.2 for your project attached.&lt;br /&gt; 2. There are several differences between the 2 releases. The major difference related to your case&lt;br /&gt; is that&amp;nbsp; 9.10.2 don&amp;#39;t support any Misra98 or Misra 2004 as 8.50.9.&lt;br /&gt; 3. The other thing is the EMbeddedTrust setting is different.&lt;br /&gt; 4. None of these changes explain the error since my understanding is Misra C 98/04 are disabled in your 8.50.9&lt;br /&gt; project as well as EmbeddedTrust.&lt;br /&gt; 5. I will send all this information to IAR back office and wait for thier response.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Variable "sec_mode" is used uninitialized at this location in the sourcecode</title><link>https://devzone.nordicsemi.com/thread/320208?ContentTypeID=1</link><pubDate>Thu, 15 Jul 2021 10:33:46 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a0ad3315-49e9-4acf-a2ec-81c5d669706a</guid><dc:creator>Karl Ylvisaker</dc:creator><description>[quote user="Renix"]Correct, No changes. I use the example directly from the nRF5 SDK.[/quote]
&lt;p&gt;Thank you for clarifying.&lt;/p&gt;
[quote user="Renix"]The IAR error is a compiler issue, but the&amp;nbsp;&lt;span&gt;uninitialized&amp;nbsp;&lt;/span&gt;&lt;span&gt;Variable &amp;quot;sec_mode&amp;quot; could be fixed on the code side, (Nordic side)&lt;/span&gt;[/quote]
&lt;p&gt;Which compiler and compiler version if this IAR version using, and what did it use before?&lt;br /&gt;The sec_mode variable is actually populated by&amp;nbsp; the&amp;nbsp;BLE_GAP_CONN_SEC_MODE_SET_OPEN macro, so I do not know why the IAR compiler suddenly complains about this. Does the changelog between the two versions mention any changes to the compiler, if so, which?&lt;br /&gt;&lt;br /&gt;Best regards,&lt;br /&gt;Karl&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Variable "sec_mode" is used uninitialized at this location in the sourcecode</title><link>https://devzone.nordicsemi.com/thread/320111?ContentTypeID=1</link><pubDate>Wed, 14 Jul 2021 20:56:01 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3c97c931-ecb0-4234-bea8-e15f737697b3</guid><dc:creator>Renix</dc:creator><description>&lt;p&gt;Karl,&lt;/p&gt;
&lt;p&gt;Correct, No changes. I use the example directly from the nRF5 SDK.&lt;/p&gt;
&lt;p&gt;I tried to compile with Optimization set to High, and then None, with the same result.&lt;/p&gt;
&lt;p&gt;The IAR error is a compiler issue, but the&amp;nbsp;&lt;span&gt;uninitialized&amp;nbsp;&lt;/span&gt;&lt;span&gt;Variable &amp;quot;sec_mode&amp;quot; could be fixed on the code side, (Nordic side)&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Regards&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Variable "sec_mode" is used uninitialized at this location in the sourcecode</title><link>https://devzone.nordicsemi.com/thread/320096?ContentTypeID=1</link><pubDate>Wed, 14 Jul 2021 16:14:41 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:900329fc-7a7d-4ce0-a1a4-bdd186997a54</guid><dc:creator>Karl Ylvisaker</dc:creator><description>[quote user="Renix"]Thanks for the reply[/quote]
&lt;p&gt;No problem at all, I am happy to help!&lt;/p&gt;
[quote user="Renix"]I do not understand why earlier versions of IAR compiled OK, and past 9.xx shows the error, but it sounds a fix in the code is needed?[/quote]
&lt;p&gt;Could it be that the newer version is compiling with a different optimization level, for example?&lt;br /&gt;Or could it be that the newer IAR version uses a different compiler, or different compiler version than the previous version? This should all be specified in the changelog for the newer version, if it is the case.&lt;br /&gt;&lt;br /&gt;Do I also understand you correctly that you have made no changes to the BLE UART example prior to running it with the newer IAR version, and suddenly getting this error?&lt;br /&gt;&lt;br /&gt;Best regards,&lt;br /&gt;Karl&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Variable "sec_mode" is used uninitialized at this location in the sourcecode</title><link>https://devzone.nordicsemi.com/thread/320092?ContentTypeID=1</link><pubDate>Wed, 14 Jul 2021 16:08:45 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:137bb198-0c14-4bd1-80ff-34ca666e3ec3</guid><dc:creator>Renix</dc:creator><description>&lt;p&gt;Karl,&lt;/p&gt;
&lt;p&gt;Thanks for the reply, but this sounds like a bug in the UART example code?&lt;/p&gt;
&lt;p&gt;I do not understand why earlier versions of IAR compiled OK, and past 9.xx shows the error, but it sounds a fix in the code is needed?&lt;/p&gt;
&lt;p&gt;Regards&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Variable "sec_mode" is used uninitialized at this location in the sourcecode</title><link>https://devzone.nordicsemi.com/thread/320018?ContentTypeID=1</link><pubDate>Wed, 14 Jul 2021 12:29:20 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fe311403-1e22-4b88-ad39-afeaff5bdeb8</guid><dc:creator>Karl Ylvisaker</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
[quote user=""]Error[Go029]: Variable &amp;quot;sec_mode&amp;quot; is used uninitialized at this location in the sourcecode.[/quote]
&lt;p&gt;This is a common compiler error, and it says that you are using the sec_mode variable, without having initialized it - so it may be any random value at the time of use.&lt;br /&gt;Please look at the mentioned line 156 of your main.c. Make sure that the sec_mode variable is initialized before it is passed to a function.&lt;br /&gt;Please see &lt;a href="https://stackoverflow.com/questions/7975008/initializing-variables-in-c"&gt;this stack overflow ticket for more information about why you almost always should initialize your variables&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;If this is not the solution to your problem, please share the entire function which encompasses line 156 of your main.c file. Please use the&amp;nbsp;&lt;em&gt;Insert -&amp;gt; Code&lt;/em&gt; option when sharing code here on DevZone.&lt;br /&gt;&lt;br /&gt;Best regards,&lt;br /&gt;Karl&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>