Opened 9 years ago
Closed 9 years ago
#8726 closed Bugs (fixed)
GCC 4.8 warns of variable set but not used
Reported by: | Owned by: | Robert Ramey | |
---|---|---|---|
Milestone: | Boost 1.54.0 | Component: | serialization |
Version: | Boost Development Trunk | Severity: | Problem |
Keywords: | Cc: |
Description
When compiling with -Wall (GCC 4.8.0) the following warning is raised as an error:
libs/serialization/src/basic_iarchive.cpp: In member function ‘const boost::archive::detail::basic_pointer_iserializer* boost::archive::detail::basic_iarchive_impl::load_pointer(boost::archive::detail::basic_iarchive&, void*&, const boost::archive::detail::basic_pointer_iserializer*, const boost::archive::detail::basic_pointer_iserializer* (*)(const boost::serialization::extended_type_info&))’: libs/serialization/src/basic_iarchive.cpp:455:23: error: variable ‘new_cid’ set but not used [-Werror=unused-but-set-variable] class_id_type new_cid = register_type(bpis_ptr->get_basic_serializer());
new_cid is only used to perform a BOOST_ASSERT, maybe this could be collapsed into one line?
Index: libs/serialization/src/basic_iarchive.cpp =================================================================== --- libs/serialization/src/basic_iarchive.cpp (revision 84899) +++ libs/serialization/src/basic_iarchive.cpp (working copy) @@ -452,10 +452,9 @@ bpis_ptr = (*finder)(*eti); } BOOST_ASSERT(NULL != bpis_ptr); - class_id_type new_cid = register_type(bpis_ptr->get_basic_serializer()); + BOOST_ASSERT(register_type(bpis_ptr->get_basic_serializer()) == cid); int i = cid; cobject_id_vector[i].bpis_ptr = bpis_ptr; - BOOST_ASSERT(new_cid == cid); } int i = cid; cobject_id & co = cobject_id_vector[i];
Attachments (1)
Change History (8)
comment:1 by , 9 years ago
Resolution: | → invalid |
---|---|
Status: | new → closed |
comment:2 by , 9 years ago
Resolution: | invalid |
---|---|
Status: | closed → reopened |
True, but it would still be nice to silence the unused warning. Could you use BOOST_VERIFY instead of BOOST_ASSERT?
comment:3 by , 9 years ago
Resolution: | → fixed |
---|---|
Status: | reopened → closed |
Ok _ i patched this. Subject to test
comment:5 by , 9 years ago
Resolution: | fixed |
---|---|
Status: | closed → reopened |
Still awaiting changeset, could this be closed only once the changeset has been committed and linked here.
comment:6 by , 9 years ago
I have attached a simpler patch; this version is unlikely to break anything else since it only adds a cast to void
to avoid the warning.
Hmmm - this wouldn't work.
It would mean that when compiling for release mode, the register_type function wouldn't get called.
Note that this will only emit the warning in debug mode.
I'm going to mark this idea as not valid - feel free to re-open if if you get a better idea.
RObert Ramey