<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Recent changes to CharVar</title><link>https://sourceforge.net/p/cppcheck/wiki/CharVar/</link><description>Recent changes to CharVar</description><atom:link href="https://sourceforge.net/p/cppcheck/wiki/CharVar/feed" rel="self"/><language>en</language><lastBuildDate>Tue, 30 Sep 2014 12:58:57 -0000</lastBuildDate><atom:link href="https://sourceforge.net/p/cppcheck/wiki/CharVar/feed" rel="self" type="application/rss+xml"/><item><title>CharVar modified by Daniel Marjamäki</title><link>https://sourceforge.net/p/cppcheck/wiki/CharVar/</link><description>&lt;div class="markdown_content"&gt;&lt;h2 id="dangerous-usage-of-char-variables"&gt;Dangerous usage of char variables&lt;/h2&gt;
&lt;p&gt;Using char variables is not always safe.&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span class="kt"&gt;char&lt;/span&gt; &lt;span class="n"&gt;s8&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mh"&gt;0xff&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kt"&gt;char&lt;/span&gt; &lt;span class="n"&gt;ch1&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;str&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;s8&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;    &lt;span class="c1"&gt;// str[s8] = str[0xffffffff]&lt;/span&gt;
&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;result1&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="n"&gt;s8&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;  &lt;span class="c1"&gt;// 1 | s8 =&amp;gt; 1 | 0xffffffff&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;cppcheck detects these problems.&lt;/p&gt;
&lt;p&gt;There will be false positives if either:&lt;br /&gt;
- It's the intended behaviour&lt;br /&gt;
- You know the variable will never have dangerous values&lt;/p&gt;
&lt;p&gt;Because of the false positives, this check is in the "--all" checks.&lt;/p&gt;&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Daniel Marjamäki</dc:creator><pubDate>Tue, 30 Sep 2014 12:58:57 -0000</pubDate><guid>https://sourceforge.netcbfbe6adb2f6e8d972eeb3137a4a09cd4c88e406</guid></item></channel></rss>