<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Wed Feb 07 22:04:45 UTC 2024

It is possible to restrict the fields that are returned in this document by specifying the 'field' parameter in your request.
For example, to request only the issue key and summary append 'field=key&field=summary' to the URL of your request.
-->
<rss version="0.92" >
<channel>
    <title>MongoDB Jira</title>
    <link>https://jira.mongodb.org</link>
    <description>This file is an XML representation of an issue</description>
    <language>en-us</language>    <build-info>
        <version>9.7.1</version>
        <build-number>970001</build-number>
        <build-date>13-04-2023</build-date>
    </build-info>


<item>
            <title>[CXX-2055] Set /EHsc when building on Visual Studio</title>
                <link>https://jira.mongodb.org/browse/CXX-2055</link>
                <project id="11980" key="CXX">C++ Driver</project>
                    <description>&lt;p&gt;When running tests on Visual Studio 2017 in &lt;a href=&quot;https://jira.mongodb.org/browse/CXX-2042&quot; title=&quot;Add MongoDB 4.4 test tasks to evergreen&quot; class=&quot;issue-link&quot; data-issue-key=&quot;CXX-2042&quot;&gt;&lt;del&gt;CXX-2042&lt;/del&gt;&lt;/a&gt;, test failures were observed that indicated destructors were not being called in tests that expected an exception to be thrown.&lt;/p&gt;

&lt;p&gt;The compiler output when building the &lt;tt&gt;test_driver&lt;/tt&gt;&#160;target produced the multiple warnings like this one:&lt;/p&gt;
&lt;p/&gt;
&lt;div id=&quot;syntaxplugin&quot; class=&quot;syntaxplugin&quot; style=&quot;border: 1px dashed #bbb; border-radius: 5px !important; overflow: auto; max-height: 30em;&quot;&gt;
&lt;table cellspacing=&quot;0&quot; cellpadding=&quot;0&quot; border=&quot;0&quot; width=&quot;100%&quot; style=&quot;font-size: 1em; line-height: 1.4em !important; font-weight: normal; font-style: normal; color: black;&quot;&gt;
		&lt;tbody &gt;
				&lt;tr id=&quot;syntaxplugin_code_and_gutter&quot;&gt;
						&lt;td  style=&quot; line-height: 1.4em !important; padding: 0em; vertical-align: top;&quot;&gt;
					&lt;pre style=&quot;font-size: 1em; margin: 0 10px;  margin-top: 10px;   width: auto; padding: 0;&quot;&gt;&lt;span style=&quot;color: black; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt;C:\code\mongo-cxx-driver\src\mongocxx\test\model\insert_one.cpp(33,9): warning C4530: C++ exception handler used, but unwind semantics are not enabled. Specify /EHsc [C:\code\mongo-cxx-driver\cmake-build\src\mongocxx\test\test_driver.vc&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
				&lt;tr id=&quot;syntaxplugin_code_and_gutter&quot;&gt;
						&lt;td  style=&quot; line-height: 1.4em !important; padding: 0em; vertical-align: top;&quot;&gt;
					&lt;pre style=&quot;font-size: 1em; margin: 0 10px;   margin-bottom: 10px;  width: auto; padding: 0;&quot;&gt;&lt;span style=&quot;color: black; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt;xproj]&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
			&lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;
&lt;p/&gt;
&lt;p&gt;Sure enough, setting &lt;tt&gt;/EHcs&lt;/tt&gt; for building tests resolved the issue.&lt;/p&gt;

&lt;p&gt;However, it is not clear to me why this is not the default behavior for C++ exception handling, and whether we need to make a change in our documentation or cmake scripts to account for this.&lt;/p&gt;

&lt;p&gt;This page indicates that &lt;tt&gt;/EHcs&lt;/tt&gt; should be the default.&lt;br/&gt;
 &lt;a href=&quot;https://docs.microsoft.com/en-us/cpp/cpp/exception-handling-in-visual-cpp?view=vs-2017&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://docs.microsoft.com/en-us/cpp/cpp/exception-handling-in-visual-cpp?view=vs-2017&lt;/a&gt;&lt;/p&gt;
&lt;blockquote&gt;&lt;p&gt;Use an /EH compiler option to specify the exception handling model to use in a C++ project. Standard C++ exception handling (/EHsc) is the default in new C++ projects in Visual Studio.&lt;font color=&quot;#172b4d&quot;&gt;&#160;&lt;/font&gt;&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;Though this page indicates that the default behavior may only partially support standard C++ exception handling:&lt;br/&gt;
 &lt;a href=&quot;https://docs.microsoft.com/en-us/cpp/build/reference/eh-exception-handling-model?view=vs-2017#default-exception-handling-behavior&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://docs.microsoft.com/en-us/cpp/build/reference/eh-exception-handling-model?view=vs-2017#default-exception-handling-behavior&lt;/a&gt;&lt;/p&gt;
&lt;blockquote&gt;&lt;p&gt;The compiler always generates code that supports asynchronous structured exception handling (SEH). By default (that is, if no /EHsc, /EHs, or /EHa option is specified), the compiler supports SEH handlers in the native C++ catch(...) clause. However, it also generates code that only partially supports C++ exceptions. The default exception unwinding code doesn&apos;t destroy automatic C++ objects outside of try blocks that go out of scope because of an exception. Resource leaks and undefined behavior may result when a C++ exception is thrown.&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;Additionally, this &lt;a href=&quot;https://stackoverflow.com/a/37164776/774658&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;StackOverflow answer&lt;/a&gt; indicates that crossing the &lt;tt&gt;extern C&lt;/tt&gt; boundary requires setting &lt;tt&gt;/EHs&lt;/tt&gt;. This may be relevant to the implementation of the &lt;tt&gt;with_transaction&lt;/tt&gt; helper, which calls a C++ supplied callback through a libmongoc function. &lt;a href=&quot;https://github.com/mongodb/mongo-cxx-driver/blob/master/src/mongocxx/client_session.hpp#L144-L166&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo-cxx-driver/blob/master/src/mongocxx/client_session.hpp#L144-L166&lt;/a&gt;&lt;/p&gt;
&lt;ul class=&quot;alternate&quot; type=&quot;square&quot;&gt;
	&lt;li&gt;Is &lt;tt&gt;/EHcs&lt;/tt&gt; only necessary for our tests?&lt;/li&gt;
	&lt;li&gt;Should we always specify &lt;tt&gt;/EHcs&lt;/tt&gt; when compiling with MSVC?&lt;/li&gt;
	&lt;li&gt;If not, should we document this for users?&lt;/li&gt;
&lt;/ul&gt;
</description>
                <environment></environment>
        <key id="1383840">CXX-2055</key>
            <summary>Set /EHsc when building on Visual Studio</summary>
                <type id="3" iconUrl="https://jira.mongodb.org/secure/viewavatar?size=xsmall&amp;avatarId=14718&amp;avatarType=issuetype">Task</type>
                                            <priority id="3" iconUrl="https://jira.mongodb.org/images/icons/priorities/major.svg">Major - P3</priority>
                        <status id="6" iconUrl="https://jira.mongodb.org/images/icons/statuses/closed.png" description="The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.">Closed</status>
                    <statusCategory id="3" key="done" colorName="success"/>
                                    <resolution id="13203">Gone away</resolution>
                                        <assignee username="-1">Unassigned</assignee>
                                    <reporter username="kevin.albertson@mongodb.com">Kevin Albertson</reporter>
                        <labels>
                    </labels>
                <created>Thu, 18 Jun 2020 14:25:16 +0000</created>
                <updated>Fri, 27 Oct 2023 19:48:20 +0000</updated>
                            <resolved>Thu, 12 Jan 2023 17:42:30 +0000</resolved>
                                                                                        <votes>0</votes>
                                    <watches>2</watches>
                                                                                                                <comments>
                            <comment id="5109624" author="kevin.albertson" created="Thu, 12 Jan 2023 17:42:04 +0000"  >&lt;p&gt;Configuring the C++ driver version 3.7.0 and older with C++17 in Visual Studio must also include the &lt;tt&gt;/EHsc&lt;/tt&gt; flag:&lt;/p&gt;
&lt;p/&gt;
&lt;div id=&quot;syntaxplugin&quot; class=&quot;syntaxplugin&quot; style=&quot;border: 1px dashed #bbb; border-radius: 5px !important; overflow: auto; max-height: 30em;&quot;&gt;
&lt;table cellspacing=&quot;0&quot; cellpadding=&quot;0&quot; border=&quot;0&quot; width=&quot;100%&quot; style=&quot;font-size: 1em; line-height: 1.4em !important; font-weight: normal; font-style: normal; color: black;&quot;&gt;
		&lt;tbody &gt;
				&lt;tr id=&quot;syntaxplugin_code_and_gutter&quot;&gt;
						&lt;td  style=&quot; line-height: 1.4em !important; padding: 0em; vertical-align: top;&quot;&gt;
					&lt;pre style=&quot;font-size: 1em; margin: 0 10px;  margin-top: 10px;   width: auto; padding: 0;&quot;&gt;&lt;span style=&quot;color: black; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt;&apos;C:\Program Files (x86)\CMake\bin\cmake.exe&apos; .. \&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
				&lt;tr id=&quot;syntaxplugin_code_and_gutter&quot;&gt;
						&lt;td  style=&quot; line-height: 1.4em !important; padding: 0em; vertical-align: top;&quot;&gt;
					&lt;pre style=&quot;font-size: 1em; margin: 0 10px;   width: auto; padding: 0;&quot;&gt;&lt;span style=&quot;color: black; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt;    -G &quot;Visual Studio 15 2017 Win64&quot;            \&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
				&lt;tr id=&quot;syntaxplugin_code_and_gutter&quot;&gt;
						&lt;td  style=&quot; line-height: 1.4em !important; padding: 0em; vertical-align: top;&quot;&gt;
					&lt;pre style=&quot;font-size: 1em; margin: 0 10px;   width: auto; padding: 0;&quot;&gt;&lt;span style=&quot;color: black; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt;    -DCMAKE_CXX_STANDARD=17                     \&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
				&lt;tr id=&quot;syntaxplugin_code_and_gutter&quot;&gt;
						&lt;td  style=&quot; line-height: 1.4em !important; padding: 0em; vertical-align: top;&quot;&gt;
					&lt;pre style=&quot;font-size: 1em; margin: 0 10px;   width: auto; padding: 0;&quot;&gt;&lt;span style=&quot;color: black; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt;    -DCMAKE_CXX_FLAGS=&quot;/Zc:__cplusplus /EHsc&quot;   \&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
				&lt;tr id=&quot;syntaxplugin_code_and_gutter&quot;&gt;
						&lt;td  style=&quot; line-height: 1.4em !important; padding: 0em; vertical-align: top;&quot;&gt;
					&lt;pre style=&quot;font-size: 1em; margin: 0 10px;   width: auto; padding: 0;&quot;&gt;&lt;span style=&quot;color: black; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt;    -DCMAKE_PREFIX_PATH=C:\mongo-c-driver       \&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
				&lt;tr id=&quot;syntaxplugin_code_and_gutter&quot;&gt;
						&lt;td  style=&quot; line-height: 1.4em !important; padding: 0em; vertical-align: top;&quot;&gt;
					&lt;pre style=&quot;font-size: 1em; margin: 0 10px;   margin-bottom: 10px;  width: auto; padding: 0;&quot;&gt;&lt;span style=&quot;color: black; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt;    -DCMAKE_INSTALL_PREFIX=C:\mongo-cxx-driver  \&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
			&lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;
&lt;p/&gt;
&lt;p&gt;The installation documentation incorrectly did not include &lt;tt&gt;/EHsc&lt;/tt&gt;.&lt;/p&gt;

&lt;p&gt;&lt;tt&gt;/EHsc&lt;/tt&gt; is the &lt;a href=&quot;https://learn.microsoft.com/en-us/cpp/cpp/exception-handling-in-visual-cpp?view=msvc-170&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;documented default&lt;/a&gt; for the exception handling model. Omitting the &lt;tt&gt;/EHsc&lt;/tt&gt; may result in incorrect stack unwinding behavior. Omitting the &lt;tt&gt;/EHsc&lt;/tt&gt; flag results in an Internal Compiler error when building tests on Visual Studio 2022.&lt;/p&gt;

&lt;p&gt;In 3.7.1 and newer, this is resolved by &lt;a href=&quot;https://jira.mongodb.org/browse/CXX-2629&quot; title=&quot;Remove requirement to set `/Zc:__cplusplus` in MSVC flags&quot; class=&quot;issue-link&quot; data-issue-key=&quot;CXX-2629&quot;&gt;&lt;del&gt;CXX-2629&lt;/del&gt;&lt;/a&gt;. The fix of &lt;a href=&quot;https://jira.mongodb.org/browse/CXX-2629&quot; title=&quot;Remove requirement to set `/Zc:__cplusplus` in MSVC flags&quot; class=&quot;issue-link&quot; data-issue-key=&quot;CXX-2629&quot;&gt;&lt;del&gt;CXX-2629&lt;/del&gt;&lt;/a&gt; longer requires CMAKE_CXX_FLAGS to be specified.&lt;/p&gt;</comment>
                            <comment id="3214393" author="kevin.albertson" created="Thu, 18 Jun 2020 15:54:53 +0000"  >&lt;p&gt;Note, the server sets this as well:&#160;&lt;a href=&quot;https://github.com/mongodb/mongo/blob/v4.2/SConstruct/#L1644-L1646&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo/blob/v4.2/SConstruct/#L1644-L1646&lt;/a&gt;&lt;/p&gt;</comment>
                    </comments>
                <issuelinks>
                            <issuelinktype id="10012">
                    <name>Related</name>
                                            <outwardlinks description="related to">
                                        <issuelink>
            <issuekey id="1382784">CXX-2054</issuekey>
        </issuelink>
            <issuelink>
            <issuekey id="2223152">CXX-2629</issuekey>
        </issuelink>
                            </outwardlinks>
                                                        </issuelinktype>
                    </issuelinks>
                <attachments>
                    </attachments>
                <subtasks>
                    </subtasks>
                <customfields>
                                                                                                                                                                                                                                                                                                                                                                    <customfield id="customfield_15850" key="com.atlassian.jira.plugins.jira-development-integration-plugin:devsummary">
                        <customfieldname>Development</customfieldname>
                        <customfieldvalues>
                            
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        <customfield id="customfield_12550" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>2|hr6iwf:</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10558" key="com.pyxis.greenhopper.jira:gh-global-rank">
                        <customfieldname>Rank (Obsolete)</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>9223372036854775807</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            </customfields>
    </item>
</channel>
</rss>