[Boost-bugs] [Boost C++ Libraries] #1278: declaration of 'str' shadows a member of 'this'

Subject: [Boost-bugs] [Boost C++ Libraries] #1278: declaration of 'str' shadows a member of 'this'
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2007-09-24 03:18:49


#1278: declaration of 'str' shadows a member of 'this'
-------------------------------------------------------+--------------------
 Reporter: James Boyden <jboyden_at_[hidden]> | Owner: samuel_krempp
     Type: Bugs | Status: new
Milestone: To Be Determined | Component: format
  Version: Boost 1.34.1 | Severity: Problem
 Keywords: |
-------------------------------------------------------+--------------------
 When using `boost::format` and compiling with G++ with the `-Wshadow`
 option enabled, the following warning is generated:
 {{{
 /usr/include/boost/format/format_implementation.hpp:28: warning:
 declaration of 'str' shadows a member of 'this'
 }}}

 The relevant lines of code are:
 {{{
     template< class Ch, class Tr, class Alloc>
     basic_format<Ch, Tr, Alloc>:: basic_format(const Ch* str)
         : style_(0), cur_arg_(0), num_args_(0), dumped_(false),
           exceptions_(io::all_error_bits)
     {
         if( str)
             parse( str );
     }

 #if !defined(BOOST_NO_STD_LOCALE)
     template< class Ch, class Tr, class Alloc>
     basic_format<Ch, Tr, Alloc>:: basic_format(const Ch* str, const
 std::locale & loc)
         : style_(0), cur_arg_(0), num_args_(0), dumped_(false),
           loc_(loc), exceptions_(io::all_error_bits)
     {
         if(str) parse( str );
     }
 }}}

 This problem would be easily fixed by changing the local variable `str` to
 `s` -- as is already the case in the next function:
 {{{
     template< class Ch, class Tr, class Alloc>
     basic_format<Ch, Tr, Alloc>:: basic_format(const string_type& s, const
 std::locale & loc)
         : style_(0), cur_arg_(0), num_args_(0), dumped_(false),
           loc_(loc), exceptions_(io::all_error_bits)
     {
         parse(s);
     }
 }}}

--
Ticket URL: <http://svn.boost.org/trac/boost/ticket/1278>
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:49:56 UTC