Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>This is a bug in the Visual C++ Standard Library implementation. The global error category objects are implemented using static data members of a class template. Unfortunately, within a single translation unit (a.k.a. source file), these data members will be initialized <em>after</em> all other namespace-scope objects in the translation unit and will be destroyed <em>before</em> those objects (because destruction occurs in reverse order of initialization).</p> <p>My recommendation would be to avoid calling <code>generic_category()</code>, <code>iostream_category()</code>, or <code>system_category()</code> during initialization and termination (i.e., before all static objects have been initialized or after destruction of static objects has begun).</p> <p>If this is not possible, the following workaround <em>may</em> work. It's worked in the few simple tests I've run, but I can't make any guarantees about its behavior in all cases (this isn't an "official" workaround; it's just a potential workaround). Add a .cpp file to your project with these contents:</p> <pre><code>// This is a workaround for a bug in the Visual C++ 2012 implementation of the // global error category objects--generic_category(), iostream_category(), and // system_category(). #ifdef _MSC_VER #if _MSC_VER != 1700 # error Please verify that this fix is still required and is still correct! #endif #include &lt;system_error&gt; // Ensure that static objects in this translation unit get initialized "first": #pragma warning(suppress: 4073) #pragma init_seg(lib) // Explicitly instantiate the global error objects in this translation unit: template struct std::_Error_objects&lt;int&gt;; #endif // _MSC_VER </code></pre> <p>The <code>#pragma init_seg(lib)</code> should ensure that static data members of <code>_Error_objects&lt;int&gt;</code> will be initialized before any static objects in user code. Do not put anything else in this source file: the <code>#pragma init_seg</code> applies to all objects in the translation unit. <code>_Error_objects</code> is an implementation detail, and that implementation detail may change at any time, hence the compiler version checks.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload