Boost logo

Boost Users :

Subject: [Boost-users] Boost 1.54.0 Header Warnings: Shadowed Variables
From: Tom Browder (tom.browder_at_[hidden])
Date: 2013-11-08 19:31:25


I am trying to use Boost 1.54.0 to replace a previous version (1.47)
and am using g++ 4.7 with most warnings turned on. I am getting many
-Wshadow errors and wonder why they exist. Surely the developers test
for such.

Here is one example from xpressive/detail/utility/hash_peek_bitset.hpp:

Both 'icase' and 'count' are reported to shadow members of 'this'.

Note that the bool arg is named 'icase' but the compiler reports
'this' has a member named 'icase' (as can be plainly seen below). In
this example it's fairly clear what is intended, but then again maybe
not (and it doesn't give the user much confidence in the code). It
isn't good practice IMHO to do such so that is why I like to use some
prefix or suffix to disambiguate the two variables.

    // Make sure all sub-expressions being merged have the same case-sensitivity
    bool test_icase_(bool icase)
    {
        std::size_t count = this->bset_.count();

        if(256 == count)
        {
            return false; // all set already, nothing to do
        }
        else if(0 != count && this->icase_ != icase)
        {
            this->set_all(); // icase mismatch! set all and bail
            return false;
        }

        this->icase_ = icase;
        return true;
    }

I could file many bugs but it begs the question of why the warnings
are allowed in the first place.

Suggestions?

Thanks and best regards,

-Tom


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net