Boost logo

Boost :

From: Stephan T. Lavavej (stl_at_[hidden])
Date: 2003-11-15 22:39:11


Hi,

Boost CVS from November 15, 2003 does not compile cleanly under gcc's
-Wshadow. I have previously pointed out similar problems in date_time and
tokenizer (in this message:
http://lists.boost.org/MailArchives/boost/msg52632.php) and they were fixed
rapidly. I've only just now tried to compile an application using regex.

I'll only quote the relevant portions of lines, not the full lines
themselves.

In boost/regex/v4/regex_compile.hpp:

Line 1329:
    set_expression(const charT* p, const charT* end, flag_type f)
The argument end shadows a member function named end.
The fix is to rename the argument and all uses of that argument.

Line 1425:
    traits_size_type syntax = traits_inst.syntax_type(c);
This shadows Line 1391:
    traits_size_type syntax = traits_inst.syntax_type(c);
The fix is to rename the second syntax and all uses of it. (Because the
code is very complicated and the shadowing is not as simple as an argument
colliding with a member function, I am extremely hesitant to fix this
myself.)

Line 1548:
    traits_size_type syntax = traits_inst.syntax_type(c);
This ALSO shadows Line 1391.

Line 1884:
    re_detail::re_syntax_base* base = STUFF;
This shadows Line 1349:
    const charT* base = p;
This shadowing is in some sense even worse.

Line 2028:
    add_simple(STUFF, STUFF, unsigned int size)
The argument size shadows a member function named size.

Line 250:
    parse_range(const charT*& ptr, const charT* end, unsigned& min,
unsigned& max)
Again we have end being shadowed.

Line 328:
    parse_escape(const charT*& first, const charT* last)
The argument first shadows a protected member function named first.

Line 681:
    move_offsets(re_detail::re_syntax_base* j, unsigned size)
Again we have size being shadowed.

Line 734:
    compile_set(const charT*& first, const charT* last)
Again we have first being shadowed.

Line 927:
    traits_size_type c = (traits_size_type)(traits_uchar_type)*first;
This shadows Line 759:
    traits_size_type c = (traits_size_type)(traits_uchar_type)*first;

Line 930:
    traits_size_type syntax = traits_inst.syntax_type(c);
This shadows Line 762:
    traits_size_type syntax = traits_inst.syntax_type(c);

Line 2088:
    fixup_leading_rep(re_detail::re_syntax_base* dat,
re_detail::re_syntax_base* end)
Again we have end being shadowed.

Line 237:
    skip_space(const charT*& first, const charT* last)
Again we have first being shadowed.

Line 1201:
    boost::uint_fast32_t flags = 0;
This shadows a member function named flags.

Line 208:
    parse_inner_set(const charT*& first, const charT* last)
Again we have first being shadowed.

In boost/regex/v4/perl_matcher_non_recursive.hpp:

Line 109:
    saved_single_repeat(unsigned c, const re_repeat* r, BidiIterator lp, int
id)
The argument id shadows a member of struct saved_state named id.

There may be others that I have not found yet.

These occurrences of shadowing produce hundreds of lines of warnings, making
-Wshadow unusable. They also are somewhat dangerous (especially the local
variables shadowing one another). They're difficult for end users to fix,
but someone familiar with the implementation should be able to fix them
easily without introducing any regressions.

Can they be fixed in time for 1.31.0?

Thanks,
Stephan T. Lavavej
http://nuwen.net

"Who knows what evil lurks in the hearts of men? Only -Wshadow knows!"


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk