Boost C++ Libraries: Ticket #6365: Compiler warnings when running static code analysis after build on MSVC 10 https://svn.boost.org/trac10/ticket/6365 <p> As the title says I'm getting several compiler warnings when running static code analysis in Visual Studio 10 (attached the list to the ticket). </p> <p> The reported warnings are harmless (are only triggered by the static analyzer and not when compiling with warning level 4), but could you fix them if you have the time? </p> <p> I'm getting two type of warnings. </p> <h2 class="section" id="Warningtype1">Warning type 1</h2> <p> warning C6246: Local declaration of 'l' hides declaration of the same name in outer scope. For additional information, see previous declaration at line '131' of 'c:\users\seppe\boost_1_48_0\boost\exception\diagnostic_information.hpp': Lines: 131 c:\users\seppe\boost_1_48_0\boost\exception\diagnostic_information.hpp 140 </p> <p> warning C6246: Local declaration of 'fn' hides declaration of the same name in outer scope. For additional information, see previous declaration at line '132' of 'c:\users\seppe\boost_1_48_0\boost\exception\diagnostic_information.hpp': Lines: 132 c:\users\seppe\boost_1_48_0\boost\exception\diagnostic_information.hpp 144 </p> <p> and the affected code: </p> <pre class="wiki">130: char const * const * f=get_error_info&lt;throw_file&gt;(*be); 131: int const * l=get_error_info&lt;throw_line&gt;(*be); 132: char const * const * fn=get_error_info&lt;throw_function&gt;(*be); 133: if( !f &amp;&amp; !l &amp;&amp; !fn ) 134: tmp &lt;&lt; "Throw location unknown (consider using BOOST_THROW_EXCEPTION)\n"; 135: else 136: { 137: if( f ) 138: { 139: tmp &lt;&lt; *f; 140: if( int const * l=get_error_info&lt;throw_line&gt;(*be) ) 141: tmp &lt;&lt; '(' &lt;&lt; *l &lt;&lt; "): "; 142: } 143: tmp &lt;&lt; "Throw in function "; 144: if( char const * const * fn=get_error_info&lt;throw_function&gt;(*be) ) 145: tmp &lt;&lt; *fn; 146: else 147: tmp &lt;&lt; "(unknown)"; 148: tmp &lt;&lt; '\n'; 149: } </pre><p> Both warnings can be fixed by: </p> <ul><li>line 140: replacing if( int const * l=get_error_info&lt;throw_line&gt;(*be) ) with if( l ) </li><li>line 144: replacing if( char const * const * fn=get_error_info&lt;throw_function&gt;(*be) ) with if( fn ) </li></ul><h2 class="section" id="Warningtype2">Warning type 2</h2> <p> Only displaying the first warning. </p> <p> warning C6246: Local declaration of 'e' hides declaration of the same name in outer scope. For additional information, see previous declaration at line '300' of 'c:\users\seppe\boost_1_48_0\boost\exception\detail\exception_ptr.hpp': Lines: 300 c:\users\seppe\boost_1_48_0\boost\exception\detail\exception_ptr.hpp 332 </p> <p> and the affected code: </p> <pre class="wiki"> 296: inline 297: exception_ptr 298: current_exception_impl() 299: { 300: exception_detail::clone_base const * e=0; &lt;&lt;snip&gt;&gt; 328: try 329: { 330: throw; 331: } 332: catch( 333: exception_detail::clone_base &amp; e ) 334: { 335: return exception_ptr(shared_ptr&lt;exception_detail::clone_base const&gt;(e.clone())); 336: } ... </pre><p> Well this is more of a false positive of the static analyzer, but can be avoided by changing the variable name of the caught exception. </p> <p> <strong>Remark</strong>: A warning is generated for each caught exception in the method (see attached list). </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/6365 Trac 1.4.3 seppe.de.clercq@… Sat, 07 Jan 2012 14:37:42 GMT attachment set https://svn.boost.org/trac10/ticket/6365 https://svn.boost.org/trac10/ticket/6365 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">warnings.txt</span> </li> </ul> <p> List of warnings </p> Ticket