<br><br><div class="gmail_quote">On Sat, Sep 17, 2011 at 1:12 PM, Matthieu Monrocq <span dir="ltr"><<a href="mailto:matthieu.monrocq@gmail.com" target="_blank">matthieu.monrocq@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

I just updated (and compiled) clang this afternoon, and a piece of code I had written simply does not work any longer.<br><br>It boils down to the following code:<br><br><div style="margin-left:40px"><font face="courier new,monospace">struct Foo {};</font><br>


</div><br><div style="margin-left:40px"><font face="courier new,monospace">void foo(unsigned u) {<br>  std::unordered_map<unsigned, Foo> map;<br>  map.insert(std::make_pair(u, Foo())); // the offending line, also occurs with a std::map<br>


}<br></font></div><font face="times new roman,serif"><br><font face="arial,helvetica,sans-serif">And I got a huge backtrace... eurk.<br><br>I managed to reduce the test case to:<br><br></font></font><div style="margin-left:40px">


<font face="times new roman,serif"><font face="arial,helvetica,sans-serif"><span style="font-family:courier new,monospace">#include <utility></span></font></font> // 1<br style="font-family:courier new,monospace">
<br style="font-family:courier new,monospace"><font face="times new roman,serif"><font face="arial,helvetica,sans-serif"><span style="font-family:courier new,monospace">template <typename V></span></font></font><br style="font-family:courier new,monospace">


<font face="times new roman,serif"><font face="arial,helvetica,sans-serif"><span style="font-family:courier new,monospace">struct Node {</span></font></font><br style="font-family:courier new,monospace"><font face="times new roman,serif"><font face="arial,helvetica,sans-serif"><span style="font-family:courier new,monospace">  V value;</span></font></font><br style="font-family:courier new,monospace">


<font face="times new roman,serif"><font face="arial,helvetica,sans-serif"><span style="font-family:courier new,monospace">  </span></font></font><br style="font-family:courier new,monospace"><font face="times new roman,serif"><font face="arial,helvetica,sans-serif"><span style="font-family:courier new,monospace">  template <typename... Args></span></font></font><br style="font-family:courier new,monospace">


<font face="times new roman,serif"><font face="arial,helvetica,sans-serif"><span style="font-family:courier new,monospace">  Node(Args&&... args): value(std::forward<Args>(args)...) {}</span></font></font> // 8<br style="font-family:courier new,monospace">


<font face="times new roman,serif"><font face="arial,helvetica,sans-serif"><span style="font-family:courier new,monospace">};</span></font></font><br style="font-family:courier new,monospace"><br style="font-family:courier new,monospace">


<font face="times new roman,serif"><font face="arial,helvetica,sans-serif"><span style="font-family:courier new,monospace">void foo(std::pair<int const, int> const& p) {</span></font></font><br style="font-family:courier new,monospace">


<font face="times new roman,serif"><font face="arial,helvetica,sans-serif"><span style="font-family:courier new,monospace">  Node<std::pair<int const, int>> node(p);</span></font></font> // 12<br style="font-family:courier new,monospace">


<font face="times new roman,serif"><font face="arial,helvetica,sans-serif"><span style="font-family:courier new,monospace">}</span></font></font><br style="font-family:courier new,monospace"></div><font face="times new roman,serif"><font face="arial,helvetica,sans-serif"><br>


Where <utility> is picked up from the MinGW implementation of gcc 4.5.2. I get this error:<br><br></font></font><div style="margin-left:40px"><font face="times new roman,serif"><font face="arial,helvetica,sans-serif"><span style="font-family:courier new,monospace">unordered_map.cpp:8:25: error: call to deleted constructor of 'std::pair<const int, int>'</span></font></font><br style="font-family:courier new,monospace">


<font face="times new roman,serif"><font face="arial,helvetica,sans-serif"><span style="font-family:courier new,monospace">  Node(Args&&... args): value(std::forward<Args>(args)...) {}</span></font></font><br style="font-family:courier new,monospace">


<font face="times new roman,serif"><font face="arial,helvetica,sans-serif"><span style="font-family:courier new,monospace">                        ^     ~~~~~~~~~~~~~~~~~~~~~~~~</span></font></font><br style="font-family:courier new,monospace">


<font face="times new roman,serif"><font face="arial,helvetica,sans-serif"><span style="font-family:courier new,monospace">unordered_map.cpp:12:35: note: in instantiation of function template specialization 'Node<std::pair<const int, </span></font></font><font face="times new roman,serif"><font face="arial,helvetica,sans-serif"><span style="font-family:courier new,monospace">int> >::Node<const std::pair<const int, int> &>' requested here</span></font></font><br style="font-family:courier new,monospace">


<font face="times new roman,serif"><font face="arial,helvetica,sans-serif"><span style="font-family:courier new,monospace">  Node<std::pair<int const, int>> node(p);</span></font></font><br style="font-family:courier new,monospace">


<font face="times new roman,serif"><font face="arial,helvetica,sans-serif"><span style="font-family:courier new,monospace">                                  ^</span></font></font><br style="font-family:courier new,monospace">


<font face="times new roman,serif"><font face="arial,helvetica,sans-serif"><span style="font-family:courier new,monospace">/mingw/lib/gcc/mingw32/4.5.2/include/c++\bits/stl_pair.h:71:12: note: function has been explicitly marked </span></font></font><font face="times new roman,serif"><font face="arial,helvetica,sans-serif"><span style="font-family:courier new,monospace">deleted here</span></font></font><br style="font-family:courier new,monospace">


<font face="times new roman,serif"><font face="arial,helvetica,sans-serif"><span style="font-family:courier new,monospace">    struct pair</span></font></font><br style="font-family:courier new,monospace"><font face="times new roman,serif"><font face="arial,helvetica,sans-serif"><span style="font-family:courier new,monospace">           ^</span></font></font><br style="font-family:courier new,monospace">


<font face="times new roman,serif"><font face="arial,helvetica,sans-serif"><span style="font-family:courier new,monospace">1 error generated.</span></font></font><br><br></div><font face="arial,helvetica,sans-serif">The full invocation (with the version of clang) and the preprocessed file can be found in attachment, for those interested.<br>


<br>I was wondering if this is a bug in the gcc 4.5.2 standard library or a bug in clang... and I'd really appreciate a work-around if anyone has one, since I'm pretty much stuck at this point.</font></blockquote>

<div><br></div><div>As a baseline, this code compiles successfully when using libc++ (compile with -stdlib=libc++, though you'll of course need to install libc++) & I seem to have a repro of your errors with libstdc++ so I'm playing around with that now.</div>
<div><br></div></div>