Skip to content
Open
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions unittests/CppInterOp/Utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,12 @@ struct DispatchInitializer {
DispatchInitializer(DispatchInitializer&&) noexcept = default;
DispatchInitializer& operator=(DispatchInitializer&&) noexcept = default;
};
// FIXME: Make this threadsafe by moving it as a function static.
DispatchInitializer g_dispatch_init;
// Thread-safe initialization using function-local static
DispatchInitializer& GetDispatchInitializer() {
static DispatchInitializer instance;
return instance;
}
DispatchInitializer& g_dispatch_init = GetDispatchInitializer();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: variable 'g_dispatch_init' provides global access to a non-const object; consider making the referenced data 'const' [cppcoreguidelines-avoid-non-const-global-variables]

DispatchInitializer& g_dispatch_init = GetDispatchInitializer();
                     ^

} // namespace
#endif

Expand Down
Loading