Skip to content

Commit ff85b54

Browse files
committed
Build with numeric conversion warnings enabled
1 parent 2f3ed10 commit ff85b54

18 files changed

+32
-33
lines changed

CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
7777
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -g")
7878
# Enable lots of warnings
7979
set(CMAKE_CXX_FLAGS
80-
"${CMAKE_CXX_FLAGS} -Wall -Wpedantic -Werror -Wswitch-enum \
80+
"${CMAKE_CXX_FLAGS} -Wall -Wpedantic -Werror -Wswitch-enum -Wconversion \
8181
-Wno-deprecated-declarations -Wno-maybe-uninitialized")
8282
elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" OR
8383
"${CMAKE_CXX_COMPILER_ID}" STREQUAL "AppleClang")
@@ -86,7 +86,7 @@ elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" OR
8686
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -g")
8787
# Enable lots of warnings
8888
set(CMAKE_CXX_FLAGS
89-
"${CMAKE_CXX_FLAGS} -Wall -Wpedantic -Werror -Wswitch-enum -Wno-deprecated-declarations")
89+
"${CMAKE_CXX_FLAGS} -Wall -Wpedantic -Werror -Wswitch-enum -Wconversion -Wno-deprecated-declarations")
9090
elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
9191
# This would be the place to enable warnings for Windows builds, although
9292
# config.inc doesn't seem to do that currently

src/goto-checker/symex_bmc.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ bool symex_bmct::should_stop_unwind(
163163

164164
bool symex_bmct::get_unwind_recursion(
165165
const irep_idt &id,
166-
unsigned thread_nr,
166+
std::size_t thread_nr,
167167
std::size_t unwind)
168168
{
169169
tvt abort_unwind_decision;

src/goto-checker/symex_bmc.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ class symex_bmct : public goto_symext
110110

111111
bool get_unwind_recursion(
112112
const irep_idt &identifier,
113-
unsigned thread_nr,
113+
std::size_t thread_nr,
114114
std::size_t unwind) override;
115115

116116
symex_coveraget symex_coverage;

src/goto-instrument/unwindset.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,14 @@ void unwindsett::parse_unwindset_one_loop(
3333
if(val.empty())
3434
return;
3535

36-
std::optional<unsigned> thread_nr;
36+
std::optional<std::size_t> thread_nr;
3737
if(isdigit(val[0]))
3838
{
3939
auto c_pos = val.find(':');
4040
if(c_pos != std::string::npos)
4141
{
4242
std::string nr = val.substr(0, c_pos);
43-
thread_nr = unsafe_string2unsigned(nr);
43+
thread_nr = unsafe_string2size_t(nr);
4444
val.erase(0, nr.size() + 1);
4545
}
4646
}
@@ -170,7 +170,7 @@ void unwindsett::parse_unwindset_one_loop(
170170

171171
if(thread_nr.has_value())
172172
{
173-
thread_loop_map[std::pair<irep_idt, unsigned>(id, *thread_nr)] = uw;
173+
thread_loop_map[std::pair<irep_idt, std::size_t>(id, *thread_nr)] = uw;
174174
}
175175
else
176176
{
@@ -188,13 +188,13 @@ void unwindsett::parse_unwindset(
188188
}
189189

190190
std::optional<unsigned>
191-
unwindsett::get_limit(const irep_idt &loop_id, unsigned thread_nr) const
191+
unwindsett::get_limit(const irep_idt &loop_id, std::size_t thread_nr) const
192192
{
193193
// We use the most specific limit we have
194194

195195
// thread x loop
196196
auto tl_it =
197-
thread_loop_map.find(std::pair<irep_idt, unsigned>(loop_id, thread_nr));
197+
thread_loop_map.find(std::pair<irep_idt, std::size_t>(loop_id, thread_nr));
198198

199199
if(tl_it != thread_loop_map.end())
200200
return tl_it->second;

src/goto-instrument/unwindset.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ class unwindsett
4444

4545
// queries
4646
std::optional<unsigned>
47-
get_limit(const irep_idt &loop, unsigned thread_id) const;
47+
get_limit(const irep_idt &loop, std::size_t thread_id) const;
4848

4949
// read unwindset directives from a file
5050
void parse_unwindset_file(
@@ -63,7 +63,7 @@ class unwindsett
6363

6464
// separate limits per thread
6565
using thread_loop_mapt =
66-
std::map<std::pair<irep_idt, unsigned>, std::optional<unsigned>>;
66+
std::map<std::pair<irep_idt, std::size_t>, std::optional<unsigned>>;
6767
thread_loop_mapt thread_loop_map;
6868

6969
void parse_unwindset_one_loop(

src/goto-programs/goto_trace.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ class goto_trace_stept
112112
goto_programt::const_targett pc;
113113

114114
// this transition done by given thread number
115-
unsigned thread_nr;
115+
std::size_t thread_nr;
116116

117117
// for assume, assert, goto
118118
bool cond_value;

src/goto-symex/complexity_limiter.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ Author: John Dumbell
1212

1313
#include "goto_symex_state.h"
1414

15-
#include <cmath>
16-
1715
complexity_limitert::complexity_limitert(
1816
message_handlert &message_handler,
1917
const optionst &options)
@@ -28,7 +26,7 @@ complexity_limitert::complexity_limitert(
2826

2927
const std::size_t failed_child_loops_limit = options.get_signed_int_option(
3028
"symex-complexity-failed-child-loops-limit");
31-
const std::size_t unwind = options.get_signed_int_option("unwind");
29+
const int unwind = options.get_signed_int_option("unwind");
3230

3331
// If we have complexity enabled, try to work out a failed_children_limit.
3432
// In order of priority:
@@ -38,7 +36,7 @@ complexity_limitert::complexity_limitert(
3836
if(failed_child_loops_limit > 0)
3937
max_loops_complexity = failed_child_loops_limit;
4038
else if(unwind > 0)
41-
max_loops_complexity = std::max(static_cast<int>(floor(unwind / 3)), 1);
39+
max_loops_complexity = std::max(unwind / 3, 1);
4240
else
4341
max_loops_complexity = limit;
4442
}

src/goto-symex/goto_symex.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -505,7 +505,7 @@ class goto_symext
505505

506506
virtual bool get_unwind_recursion(
507507
const irep_idt &identifier,
508-
unsigned thread_nr,
508+
std::size_t thread_nr,
509509
std::size_t unwind);
510510

511511
/// Iterates over \p arguments and assigns them to the parameters, which are

src/goto-symex/goto_symex_state.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ class goto_symex_statet final : public goto_statet
176176
void print_backtrace(std::ostream &) const;
177177

178178
// threads
179-
typedef std::pair<unsigned, std::list<guardt> > a_s_r_entryt;
179+
typedef std::pair<std::size_t, std::list<guardt> > a_s_r_entryt;
180180
typedef std::list<guardt> a_s_w_entryt;
181181
std::unordered_map<ssa_exprt, a_s_r_entryt, irep_hash> read_in_atomic_section;
182182
std::unordered_map<ssa_exprt, a_s_w_entryt, irep_hash>

src/goto-symex/memory_model.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ class memory_model_baset : public partial_order_concurrencyt
5757
symex_target_equationt &equation);
5858

5959
// maps thread numbers to an event list
60-
typedef std::map<unsigned, event_listt> per_thread_mapt;
60+
typedef std::map<std::size_t, event_listt> per_thread_mapt;
6161
};
6262

6363
#endif // CPROVER_GOTO_SYMEX_MEMORY_MODEL_H

0 commit comments

Comments
 (0)