<html>
<head>
<base href="https://llvm.org/bugs/" />
</head>
<body><span class="vcard"><a class="email" href="mailto:richard-llvm@metafoo.co.uk" title="Richard Smith <richard-llvm@metafoo.co.uk>"> <span class="fn">Richard Smith</span></a>
</span> changed
<a class="bz_bug_link
bz_status_RESOLVED bz_closed"
title="RESOLVED INVALID - libc++ std::map::operator[] is different (worse) than libstdc++ with C++11, move semantics, and exception handling"
href="https://llvm.org/bugs/show_bug.cgi?id=25098">bug 25098</a>
<br>
<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>What</th>
<th>Removed</th>
<th>Added</th>
</tr>
<tr>
<td style="text-align:right;">Status</td>
<td>NEW
</td>
<td>RESOLVED
</td>
</tr>
<tr>
<td style="text-align:right;">CC</td>
<td>
</td>
<td>richard-llvm@metafoo.co.uk
</td>
</tr>
<tr>
<td style="text-align:right;">Resolution</td>
<td>---
</td>
<td>INVALID
</td>
</tr></table>
<p>
<div>
<b><a class="bz_bug_link
bz_status_RESOLVED bz_closed"
title="RESOLVED INVALID - libc++ std::map::operator[] is different (worse) than libstdc++ with C++11, move semantics, and exception handling"
href="https://llvm.org/bugs/show_bug.cgi?id=25098#c1">Comment # 1</a>
on <a class="bz_bug_link
bz_status_RESOLVED bz_closed"
title="RESOLVED INVALID - libc++ std::map::operator[] is different (worse) than libstdc++ with C++11, move semantics, and exception handling"
href="https://llvm.org/bugs/show_bug.cgi?id=25098">bug 25098</a>
from <span class="vcard"><a class="email" href="mailto:richard-llvm@metafoo.co.uk" title="Richard Smith <richard-llvm@metafoo.co.uk>"> <span class="fn">Richard Smith</span></a>
</span></b>
<pre>The outcome here comes down to the (unspecified) order of evaluation. In:
uut["1"] = boost::make_shared<ThrowsInConstructor>(1);
GCC evaluates the right-hand side first, and so throws before calling
operator[] (leaving the map empty). Clang evaluates the left-hand side first,
and so throws after calling operator[] (leaving the map with a single element).
If you change the code to:
auto &elem = uut["1"];
elem = boost::make_shared<ThrowsInConstructor>(1);
or:
auto &&val = boost::make_shared<ThrowsInConstructor>(1);
uut["1"] = std::move(val);
... you'll get the same result from both compilers (map size 1 in the first
case, map size 0 in the second).</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>