Opened 13 years ago

Closed 12 years ago

#3033 closed Bugs (fixed)

Boost::Fusion: Shadow Variables and Unused Globals Cause Warnings/Errors When Headers Are Not in System Path

Reported by: gerickson@… Owned by: Joel de Guzman
Milestone: Boost 1.40.0 Component: fusion
Version: Boost 1.39.0 Severity: Problem
Keywords: Cc:

Description

I've recently added Boost to an Xcode 3.1.2 project with the following warnings enabled in GCC/G++ 4.0.1:

-Werror -Wreturn-type -Wunused-function -Wunused-label -Wunused-variable -Wshadow

Unfortunately, when boost is not installed in a "system" path--as is the case here--unused and shadow variable warnings cause the build to fail when warnings are treated as errors. This issue last came up for me about a year ago in 1_35_0 with filesystem.hpp:

http://article.gmane.org/gmane.comp.lib.boost.user/38297/match=shadow+variables+cause

The included headers this time are:

boost/accumulators/accumulators.hpp boost/accumulators/statistics/stats.hpp boost/accumulators/statistics/rolling_mean.hpp

To test and fix, I isolated with:

printf "#include <${BoostHeader}>\nint main(void) { return 0; }" | /Developer/usr/bin/gcc-4.0 -x c++ -Wall -Wshadow -Werror -o test -I${BoostRoot}/boost/include -

The patch to address this is as follows and impacts the headers below:

boost/fusion/container/list/cons.hpp boost/fusion/container/list/cons_iterator.hpp boost/fusion/container/vector/vector_iterator.hpp boost/fusion/view/filter_view/filter_view.hpp boost/fusion/view/filter_view/filter_view_iterator.hpp boost/fusion/view/iterator_range/iterator_range.hpp boost/fusion/view/joint_view/joint_view.hpp boost/fusion/view/joint_view/joint_view_iterator.hpp boost/fusion/view/single_view/single_view.hpp

Patches for other headers to be filed separately.

Because this problem seems to come up frequently, perhaps there is a way -Wshadow and -Wall can be forced for all unit tests?

Attachments (1)

boost-02.patch (5.4 KB ) - added by gerickson@… 13 years ago.
Patch for Boost::Fusion -Wshadow and -Wunused Errors

Download all attachments as: .zip

Change History (7)

by gerickson@…, 13 years ago

Attachment: boost-02.patch added

Patch for Boost::Fusion -Wshadow and -Wunused Errors

comment:1 by Marshall Clow, 13 years ago

Owner: set to Joel de Guzman

comment:2 by Marshall Clow, 13 years ago

Component: Nonefusion

comment:3 by anonymous, 13 years ago

Whoich compiler? Can you provide a test case please?

comment:4 by Marshall Clow, 13 years ago

The OP says (first sentence) I've recently added Boost to an Xcode 3.1.2 project with the following warnings enabled in GCC/G++ 4.0.1:

comment:5 by anonymous, 13 years ago

Ah darn. I should've read. I only read the email notifications when the ticket was reassigned to me. I'll fix this.

comment:6 by Steven Watanabe, 12 years ago

Resolution: fixed
Status: newclosed

(In [62869]) Clean up GCC warnings. Fixes #3033.

Note: See TracTickets for help on using tickets.