Skip to content

Commit bfe8a91

Browse files
committed
Silence Visual Studio warnings about non-thread-safe static objects
1 parent f8e8d5c commit bfe8a91

File tree

9 files changed

+81
-1
lines changed

9 files changed

+81
-1
lines changed

jbmc/src/java_bytecode/ci_lazy_methods.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,15 @@ ci_lazy_methodst::ci_lazy_methodst(
6565
/// class
6666
static bool references_class_model(const exprt &expr)
6767
{
68+
#ifdef _MSC_VER
69+
#include <util/pragma_push.def>
70+
#pragma warning(disable:4640)
71+
// construction of local static object is not thread-safe
72+
#endif
6873
static const struct_tag_typet class_type("java::java.lang.Class");
74+
#ifdef _MSC_VER
75+
#include <util/pragma_pop.def>
76+
#endif
6977

7078
for(auto it = expr.depth_begin(); it != expr.depth_end(); ++it)
7179
{

jbmc/src/java_bytecode/java_entry_point.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,17 @@ static bool should_init_symbol(const symbolt &sym)
8989
/// \return Class initializer method's symbol name.
9090
irep_idt get_java_class_literal_initializer_signature()
9191
{
92-
static irep_idt signature =
92+
#ifdef _MSC_VER
93+
#include <util/pragma_push.def>
94+
#pragma warning(disable:4640)
95+
// construction of local static object is not thread-safe
96+
#endif
97+
static const irep_idt signature =
9398
"java::java.lang.Class.cproverInitializeClassLiteral:"
9499
"(Ljava/lang/String;ZZZZZZZ)V";
100+
#ifdef _MSC_VER
101+
#include <util/pragma_pop.def>
102+
#endif
95103
return signature;
96104
}
97105

jbmc/src/java_bytecode/java_utils.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -407,9 +407,17 @@ get_inherited_component(
407407
/// \return true if this static field is known never to be null
408408
bool is_non_null_library_global(const irep_idt &symbolid)
409409
{
410+
#ifdef _MSC_VER
411+
#include <util/pragma_push.def>
412+
#pragma warning(disable:4640)
413+
// construction of local static object is not thread-safe
414+
#endif
410415
static const irep_idt in = "java::java.lang.System.in";
411416
static const irep_idt out = "java::java.lang.System.out";
412417
static const irep_idt err = "java::java.lang.System.err";
418+
#ifdef _MSC_VER
419+
#include <util/pragma_pop.def>
420+
#endif
413421
return symbolid == in || symbolid == out || symbolid == err;
414422
}
415423

jbmc/src/jbmc/jbmc_parse_options.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1049,7 +1049,15 @@ bool jbmc_parse_optionst::process_goto_functions(
10491049

10501050
bool jbmc_parse_optionst::can_generate_function_body(const irep_idt &name)
10511051
{
1052+
#ifdef _MSC_VER
1053+
#include <util/pragma_push.def>
1054+
#pragma warning(disable:4640)
1055+
// construction of local static object is not thread-safe
1056+
#endif
10521057
static const irep_idt initialize_id = INITIALIZE_FUNCTION;
1058+
#ifdef _MSC_VER
1059+
#include <util/pragma_pop.def>
1060+
#endif
10531061

10541062
return name != goto_functionst::entry_point() && name != initialize_id;
10551063
}

src/analyses/reaching_definitions.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -734,7 +734,15 @@ const rd_range_domaint::ranges_at_loct &rd_range_domaint::get(
734734
{
735735
populate_cache(identifier);
736736

737+
#ifdef _MSC_VER
738+
#include <util/pragma_push.def>
739+
#pragma warning(disable:4640)
740+
// construction of local static object is not thread-safe
741+
#endif
737742
static ranges_at_loct empty;
743+
#ifdef _MSC_VER
744+
#include <util/pragma_pop.def>
745+
#endif
738746

739747
export_cachet::const_iterator entry=export_cache.find(identifier);
740748

src/goto-instrument/wmm/event_graph.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,15 @@ class event_grapht
349349

350350
std::list<event_idt>* initial_filtering(std::list<event_idt>* order)
351351
{
352+
#ifdef _MSC_VER
353+
#include <util/pragma_push.def>
354+
#pragma warning(disable:4640)
355+
// construction of local static object is not thread-safe
356+
#endif
352357
static std::list<event_idt> new_order;
358+
#ifdef _MSC_VER
359+
#include <util/pragma_pop.def>
360+
#endif
353361

354362
/* intersection */
355363
for(const auto &evt : *order)

src/solvers/sat/satcheck_minisat2.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,14 @@ Author: Daniel Kroening, [email protected]
2020
#include <util/invariant.h>
2121
#include <util/threeval.h>
2222

23+
#include <util/pragma_push.def>
24+
#ifdef _MSC_VER
25+
#pragma warning(disable:4640)
26+
// construction of local static object is not thread-safe
27+
#endif
2328
#include <minisat/core/Solver.h>
2429
#include <minisat/simp/SimpSolver.h>
30+
#include <util/pragma_pop.def>
2531

2632
#ifndef HAVE_MINISAT2
2733
#error "Expected HAVE_MINISAT2"

src/util/irep.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,15 +209,33 @@ const irep_idt &irept::get(const irep_namet &name) const
209209
if(it==s.end() ||
210210
it->first!=name)
211211
{
212+
#ifdef _MSC_VER
213+
#include <util/pragma_push.def>
214+
#pragma warning(disable:4640)
215+
// construction of local static object is not thread-safe
216+
#endif
212217
static const irep_idt empty;
218+
#ifdef _MSC_VER
219+
#include <util/pragma_pop.def>
220+
#endif
213221
return empty;
214222
}
215223
#else
216224
named_subt::const_iterator it=s.find(name);
217225

218226
if(it==s.end())
219227
{
228+
#ifdef _MSC_VER
229+
// NOLINTNEXTLINE(build/include)
230+
#include <util/pragma_push.def>
231+
#pragma warning(disable:4640)
232+
// construction of local static object is not thread-safe
233+
#endif
220234
static const irep_idt empty;
235+
#ifdef _MSC_VER
236+
// NOLINTNEXTLINE(build/include)
237+
#include <util/pragma_pop.def>
238+
#endif
221239
return empty;
222240
}
223241
#endif

src/util/string_container.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,15 @@ class string_containert
9292
/// Get a reference to the global string container.
9393
inline string_containert &get_string_container()
9494
{
95+
#ifdef _MSC_VER
96+
#include <util/pragma_push.def>
97+
#pragma warning(disable:4640)
98+
// construction of local static object is not thread-safe
99+
#endif
95100
static string_containert ret;
101+
#ifdef _MSC_VER
102+
#include <util/pragma_pop.def>
103+
#endif
96104
return ret;
97105
}
98106

0 commit comments

Comments
 (0)