Skip to content

Commit 825e0e6

Browse files
committed
Silence Visual Studio warnings about non-thread-safe static objects
1 parent 9c4aec8 commit 825e0e6

File tree

9 files changed

+73
-1
lines changed

9 files changed

+73
-1
lines changed

jbmc/src/java_bytecode/ci_lazy_methods.cpp

+8
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

+9-1
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,17 @@ static bool should_init_symbol(const symbolt &sym)
7676

7777
irep_idt get_java_class_literal_initializer_signature()
7878
{
79-
static irep_idt signature =
79+
#ifdef _MSC_VER
80+
#include <util/pragma_push.def>
81+
#pragma warning(disable:4640)
82+
// construction of local static object is not thread-safe
83+
#endif
84+
static const irep_idt signature =
8085
"java::java.lang.Class.cproverInitializeClassLiteral:"
8186
"(Ljava/lang/String;ZZZZZZZ)V";
87+
#ifdef _MSC_VER
88+
#include <util/pragma_pop.def>
89+
#endif
8290
return signature;
8391
}
8492

jbmc/src/java_bytecode/java_utils.cpp

+8
Original file line numberDiff line numberDiff line change
@@ -519,9 +519,17 @@ get_inherited_component(
519519
/// \return true if this static field is known never to be null
520520
bool is_non_null_library_global(const irep_idt &symbolid)
521521
{
522+
#ifdef _MSC_VER
523+
#include <util/pragma_push.def>
524+
#pragma warning(disable:4640)
525+
// construction of local static object is not thread-safe
526+
#endif
522527
static const irep_idt in = "java::java.lang.System.in";
523528
static const irep_idt out = "java::java.lang.System.out";
524529
static const irep_idt err = "java::java.lang.System.err";
530+
#ifdef _MSC_VER
531+
#include <util/pragma_pop.def>
532+
#endif
525533
return symbolid == in || symbolid == out || symbolid == err;
526534
}
527535

jbmc/src/jbmc/jbmc_parse_options.cpp

+8
Original file line numberDiff line numberDiff line change
@@ -917,7 +917,15 @@ bool jbmc_parse_optionst::process_goto_functions(
917917

918918
bool jbmc_parse_optionst::can_generate_function_body(const irep_idt &name)
919919
{
920+
#ifdef _MSC_VER
921+
#include <util/pragma_push.def>
922+
#pragma warning(disable:4640)
923+
// construction of local static object is not thread-safe
924+
#endif
920925
static const irep_idt initialize_id = INITIALIZE_FUNCTION;
926+
#ifdef _MSC_VER
927+
#include <util/pragma_pop.def>
928+
#endif
921929

922930
return name != goto_functionst::entry_point() && name != initialize_id;
923931
}

src/analyses/reaching_definitions.cpp

+8
Original file line numberDiff line numberDiff line change
@@ -723,7 +723,15 @@ const rd_range_domaint::ranges_at_loct &rd_range_domaint::get(
723723
{
724724
populate_cache(identifier);
725725

726+
#ifdef _MSC_VER
727+
#include <util/pragma_push.def>
728+
#pragma warning(disable:4640)
729+
// construction of local static object is not thread-safe
730+
#endif
726731
static ranges_at_loct empty;
732+
#ifdef _MSC_VER
733+
#include <util/pragma_pop.def>
734+
#endif
727735

728736
export_cachet::const_iterator entry=export_cache.find(identifier);
729737

src/goto-instrument/wmm/event_graph.h

+8
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,15 @@ class event_grapht
348348

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

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

src/solvers/sat/satcheck_minisat2.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,14 @@ Author: Daniel Kroening, [email protected]
1818
#include <util/invariant.h>
1919
#include <util/threeval.h>
2020

21+
#include <util/pragma_push.def>
22+
#ifdef _MSC_VER
23+
#pragma warning(disable:4640)
24+
// construction of local static object is not thread-safe
25+
#endif
2126
#include <minisat/core/Solver.h>
2227
#include <minisat/simp/SimpSolver.h>
28+
#include <util/pragma_pop.def>
2329

2430
#ifndef l_False
2531
# define l_False Minisat::l_False

src/util/irep.cpp

+10
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,17 @@ const irep_idt &irept::get(const irep_idt &name) const
4848

4949
if(it==s.end())
5050
{
51+
#ifdef _MSC_VER
52+
// NOLINTNEXTLINE(build/include)
53+
#include <util/pragma_push.def>
54+
#pragma warning(disable:4640)
55+
// construction of local static object is not thread-safe
56+
#endif
5157
static const irep_idt empty;
58+
#ifdef _MSC_VER
59+
// NOLINTNEXTLINE(build/include)
60+
#include <util/pragma_pop.def>
61+
#endif
5262
return empty;
5363
}
5464
return it->second.id();

src/util/string_container.h

+8
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,15 @@ class string_containert
110110
/// Get a reference to the global string container.
111111
inline string_containert &get_string_container()
112112
{
113+
#ifdef _MSC_VER
114+
#include <util/pragma_push.def>
115+
#pragma warning(disable:4640)
116+
// construction of local static object is not thread-safe
117+
#endif
113118
static string_containert ret;
119+
#ifdef _MSC_VER
120+
#include <util/pragma_pop.def>
121+
#endif
114122
return ret;
115123
}
116124

0 commit comments

Comments
 (0)