Subject: [Boost-bugs] [Boost C++ Libraries] #6365: Compiler warnings when running static code analysis after build on MSVC 10
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2012-01-07 14:36:50
#6365: Compiler warnings when running static code analysis after build on MSVC 10
---------------------------------------+------------------------------------
Reporter: seppe.de.clercq@⦠| Owner: emildotchevski
Type: Bugs | Status: new
Milestone: To Be Determined | Component: exception
Version: Boost 1.48.0 | Severity: Cosmetic
Keywords: |
---------------------------------------+------------------------------------
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).
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?
I'm getting two type of warnings.
== Warning type 1 ==
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
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
and the affected code:
{{{
130: char const * const * f=get_error_info<throw_file>(*be);
131: int const * l=get_error_info<throw_line>(*be);
132: char const * const * fn=get_error_info<throw_function>(*be);
133: if( !f && !l && !fn )
134: tmp << "Throw location unknown (consider using
BOOST_THROW_EXCEPTION)\n";
135: else
136: {
137: if( f )
138: {
139: tmp << *f;
140: if( int const * l=get_error_info<throw_line>(*be) )
141: tmp << '(' << *l << "): ";
142: }
143: tmp << "Throw in function ";
144: if( char const * const * fn=get_error_info<throw_function>(*be) )
145: tmp << *fn;
146: else
147: tmp << "(unknown)";
148: tmp << '\n';
149: }
}}}
Both warnings can be fixed by:
- line 140: replacing if( int const *
l=get_error_info<throw_line>(*be) ) with if( l )
- line 144: replacing if( char const * const *
fn=get_error_info<throw_function>(*be) ) with if( fn )
== Warning type 2 ==
Only displaying the first warning.
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
and the affected code:
{{{
296: inline
297: exception_ptr
298: current_exception_impl()
299: {
300: exception_detail::clone_base const * e=0;
<<snip>>
328: try
329: {
330: throw;
331: }
332: catch(
333: exception_detail::clone_base & e )
334: {
335: return
exception_ptr(shared_ptr<exception_detail::clone_base const>(e.clone()));
336: }
...
}}}
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.
'''Remark''': A warning is generated for each caught exception in the
method (see attached list).
-- Ticket URL: <https://svn.boost.org/trac/boost/ticket/6365> Boost C++ Libraries <http://www.boost.org/> Boost provides free peer-reviewed portable C++ source libraries.
This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:08 UTC