Skip to content

Commit

Permalink
Update build script to compile with more warnings, and fix all the wa…
Browse files Browse the repository at this point in the history
…rnings
  • Loading branch information
ot committed Feb 20, 2013
1 parent 0fafd93 commit 9b19e20
Show file tree
Hide file tree
Showing 12 changed files with 34 additions and 21 deletions.
6 changes: 6 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@ if (SUCCINCT_USE_POPCNT)
endif ()
# XXX(ot): what to do for MSVC?
endif ()

#
# XXX(ot): enable this on all compilers
if (UNIX)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wno-missing-braces")
endif ()


find_package(Boost 1.42.0 COMPONENTS
Expand Down
2 changes: 1 addition & 1 deletion bit_vector.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -315,8 +315,8 @@ namespace succinct {
enumerator(bit_vector const& bv, size_t pos)
: m_bv(&bv)
, m_pos(pos)
, m_avail(0)
, m_buf(0)
, m_avail(0)
{
m_bv->data().prefetch(m_pos / 64);
}
Expand Down
6 changes: 3 additions & 3 deletions bp_vector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -305,14 +305,14 @@ namespace succinct {
}

inline bool bp_vector::in_node_range(uint64_t node, excess_t excess) const {
assert(m_superblock_excess_min[node] != size());
assert(m_superblock_excess_min[node] != excess_t(size()));
return excess >= m_superblock_excess_min[node];
}

template <int direction>
inline uint64_t bp_vector::search_min_tree(uint64_t block, excess_t excess) const
{
size_t found_block;
size_t found_block = -1;
if (search_block_in_superblock<direction>(block, excess, found_block)) {
return found_block;
}
Expand Down Expand Up @@ -685,7 +685,7 @@ namespace succinct {
++block) {
cur_super_min = std::min(cur_super_min, superblock_excess + block_excess_min[block]);
}
assert(cur_super_min >= 0 && cur_super_min < size());
assert(cur_super_min >= 0 && cur_super_min < excess_t(size()));

superblock_excess_min[m_internal_nodes + superblock] = cur_super_min;
}
Expand Down
4 changes: 2 additions & 2 deletions gamma_bit_vector.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ namespace succinct {
{
size_t pos = m_high_bits.select(idx);
size_t l; // ignored
return retrieve_value(idx, pos, l);
return retrieve_value(pos, l);
}

size_t size() const
Expand All @@ -72,7 +72,7 @@ namespace succinct {

private:

value_type retrieve_value(size_t idx, size_t pos, size_t& l) const
value_type retrieve_value(size_t pos, size_t& l) const
{
assert(m_high_bits.bits()[pos] == 1);
l = broadword::lsb(m_high_bits.bits().get_word(pos + 1));
Expand Down
2 changes: 1 addition & 1 deletion intrinsics.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ namespace intrinsics {
#else /* SUCCINCT_USE_INTRINSICS */

template <typename T>
inline void prefetch(T const* ptr)
inline void prefetch(T const* /* ptr */)
{
/* do nothing */
}
Expand Down
14 changes: 7 additions & 7 deletions mapper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,22 +63,22 @@ namespace mapper {

template <typename T>
typename boost::disable_if<boost::is_pod<T>, freeze_visitor&>::type
operator()(T& val, const char* friendly_name) {
operator()(T& val, const char* /* friendly_name */) {
val.map(*this);
return *this;
}

template <typename T>
typename boost::enable_if<boost::is_pod<T>, freeze_visitor&>::type
operator()(T& val, const char* friendly_name) {
operator()(T& val, const char* /* friendly_name */) {
m_fout.write(reinterpret_cast<const char*>(&val), sizeof(T));
m_written += sizeof(T);
return *this;
}

template<typename T>
freeze_visitor&
operator()(mappable_vector<T>& vec, const char* friendly_name) {
operator()(mappable_vector<T>& vec, const char* /* friendly_name */) {
(*this)(vec.m_size, "size");

size_t n_bytes = static_cast<size_t>(vec.m_size * sizeof(T));
Expand Down Expand Up @@ -111,22 +111,22 @@ namespace mapper {

template <typename T>
typename boost::disable_if<boost::is_pod<T>, map_visitor&>::type
operator()(T& val, const char* friendly_name) {
operator()(T& val, const char* /* friendly_name */) {
val.map(*this);
return *this;
}

template <typename T>
typename boost::enable_if<boost::is_pod<T>, map_visitor&>::type
operator()(T& val, const char* friendly_name) {
operator()(T& val, const char* /* friendly_name */) {
val = *reinterpret_cast<const T*>(m_cur);
m_cur += sizeof(T);
return *this;
}

template<typename T>
map_visitor&
operator()(mappable_vector<T>& vec, const char* friendly_name) {
operator()(mappable_vector<T>& vec, const char* /* friendly_name */) {
vec.clear();
(*this)(vec.m_size, "size");

Expand Down Expand Up @@ -187,7 +187,7 @@ namespace mapper {

template <typename T>
typename boost::enable_if<boost::is_pod<T>, sizeof_visitor&>::type
operator()(T& val, const char* friendly_name) {
operator()(T& /* val */, const char* /* friendly_name */) {
// don't track PODs in the size tree (they are constant sized)
m_size += sizeof(T);
return *this;
Expand Down
3 changes: 2 additions & 1 deletion perftest/perftest_bp_vector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ double time_visit(BpVector const& bp, size_t sample_size = 1000000)
random_bits.push_back(rand() > (RAND_MAX / 2));
}

volatile size_t foo; // to prevent the compiler to optimize away the loop
volatile size_t foo = 0; // to prevent the compiler to optimize away the loop

size_t find_close_performed = 0;
size_t steps_done = 0;
Expand All @@ -66,6 +66,7 @@ double time_visit(BpVector const& bp, size_t sample_size = 1000000)
}
}

(void)foo; // silence warning
return elapsed / find_close_performed;
}

Expand Down
2 changes: 1 addition & 1 deletion perftest/perftest_bp_vector_rmq.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ double time_avg_rmq(succinct::bp_vector const& bp, size_t sample_size = 1000000)
}
}

(void)foo; // silence warning
return elapsed / rmq_performed;
}

Expand All @@ -53,7 +54,6 @@ void rmq_benchmark(size_t runs)
for (size_t ln = 10; ln <= 28; ln += 2) {
size_t n = 1 << ln;
double elapsed = 0;
double bits_per_bp = 0;
for (size_t run = 0; run < runs; ++run) {
succinct::bp_vector bp;
build_random_binary_tree(bp, n);
Expand Down
2 changes: 1 addition & 1 deletion perftest/perftest_cartesian_tree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ double time_avg_rmq(succinct::cartesian_tree const& tree, size_t sample_size = 1
}
}

(void)foo; // silence warning
return elapsed / rmq_performed;
}

Expand All @@ -46,7 +47,6 @@ void rmq_benchmark(size_t runs)
for (size_t ln = 10; ln <= 28; ln += 2) {
size_t n = 1 << ln;
double elapsed = 0;
double bits_per_bp = 0;
for (size_t run = 0; run < runs; ++run) {
std::vector<uint64_t> v(n);
for (size_t i = 0; i < v.size(); ++i) {
Expand Down
10 changes: 8 additions & 2 deletions perftest/perftest_elias_fano.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
struct monotone_generator
{
monotone_generator(uint64_t m, uint8_t bits, uint64_t seed)
: m_bits(bits)
, m_gen(seed)
: m_gen(seed)
, m_bits(bits)
{
m_stack.push_back(state_t(0, m, 0));
}
Expand Down Expand Up @@ -95,12 +95,18 @@ void ef_enumeration_benchmark(uint64_t m, uint8_t bits)
}
}
volatile uint64_t vfoo = foo;
(void)vfoo; // silence warning

std::cerr << "Elapsed: " << elapsed / 1000 << " msec\n"
<< m / elapsed << " Mcodes/s" << std::endl;
}

int main(int argc, char** argv)
{
if (argc != 3) {
std::cerr << "Invalid arguments" << std::endl;
std::terminate();
}
size_t m = boost::lexical_cast<uint64_t>(argv[1]);
uint8_t bits = uint8_t(boost::lexical_cast<int>(argv[2]));

Expand Down
2 changes: 1 addition & 1 deletion test_bp_vector_common.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ namespace succinct {
builder.push_back(val);
}

for (size_t i = 0; i < excess; ++i) {
for (size_t i = 0; i < size_t(excess); ++i) {
builder.push_back(0); // close all parentheses
}
}
Expand Down
2 changes: 1 addition & 1 deletion test_topk_vector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ struct value_index_comparator {
};

template <typename TopKVector>
void test_topk(std::vector<value_type> const& v, TopKVector const& topkv, std::string test_name)
void test_topk(std::vector<value_type> const& v, TopKVector const& topkv, std::string /* test_name */)
{
BOOST_REQUIRE_EQUAL(v.size(), topkv.size());

Expand Down

0 comments on commit 9b19e20

Please sign in to comment.