Opened 15 years ago

Closed 15 years ago

Last modified 14 years ago

#1278 closed Bugs (fixed)

declaration of 'str' shadows a member of 'this'

Reported by: James Boyden <jboyden@…> Owned by: Samuel Krempp
Milestone: Boost 1.35.0 Component: format
Version: Boost 1.34.1 Severity: Problem
Keywords: Cc: esigra@…

Description

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);  
    }

Change History (2)

comment:1 by John Maddock, 15 years ago

Milestone: To Be DeterminedBoost 1.35.0
Resolution: fixed
Status: newclosed

Fixed in SVN Trunk.

comment:2 by Erik Sigra <esigra@…>, 14 years ago

Cc: esigra@… added
Note: See TracTickets for help on using tickets.