diff mbox

PR78991 make __gnu_cxx::__ops constructors explicit

Message ID 20170109110907.GF13348@redhat.com
State New
Headers show

Commit Message

Jonathan Wakely Jan. 9, 2017, 11:09 a.m. UTC
On 09/01/17 11:05 +0000, Kyrill Tkachov wrote:
>

>On 09/01/17 10:47, Jonathan Wakely wrote:

>>On 09/01/17 10:39 +0000, Kyrill Tkachov wrote:

>>>Hi Jonathan,

>>>

>>>On 06/01/17 12:40, Jonathan Wakely wrote:

>>>>This solves a problem when using libstdc++ with Clang, due to Clang

>>>>more eagerly instantiating constexpr function templates during

>>>>argument deduction. G++ has some shortcuts to avoid this problem, but

>>>>Clang doesn't, and it's not clear that it's strictly speaking a bug in

>>>>Clang or if it's following the standard. By making these constructors

>>>>explicit we stop them being considered by overload resolution for

>>>>copying these functors, which stops us ending up back in the

>>>>std::function SFINAE checks.

>>>>

>>>>I'm also using _GLIBCXX_MOVE to turn some internal copies into moves,

>>>>because otherwise using something like std::function with <algorithm>

>>>>results in a number of potentially expensive copies.

>>>>

>>>>   PR libstdc++/78991

>>>>   * include/bits/predefined_ops.h (_Iter_comp_iter, _Iter_comp_val)

>>>>   (_Val_comp_iter, _Iter_equals_val, _Iter_pred, _Iter_comp_to_val)

>>>>   (_Iter_comp_to_iter, _Iter_negate): Make constructors explicit and

>>>>   move function objects.

>>>>   (__iter_comp_iter, __iter_comp_val, __val_comp_iter, __pred_iter)

>>>>   (__iter_comp_val, __iter_comp_iter, __negate): Move function objects.

>>>>   * testsuite/25_algorithms/sort/78991.cc: New test.

>>>>

>>>>Tested powerpc64le-linux, committed to trunk.

>>>>

>>>>I'll backport  the 'explicit' constructors (but not the _GLIBCXX_MOVE

>>>>changes) to the branches too.

>>>>

>>>

>>>I see this test fail on the GCC 5 branch on arm and aarch64 (error message pasted below).

>>>Does the test need a gnu++11 guard or something on the branch?

>>

>>I thought I'd changed that before committing, I'll fix it.

>>

>Thanks.

>Also, I think 30_threads/thread/cons/lwg2097.cc needs something similar.


Yes. I fixed both those tests on my testing machine, but not on the
one where I committed from.

Committed to gcc-5-branch.
diff mbox

Patch

commit ea8019b493c1aa6b223969ec5f1153e6f381acde
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Mon Jan 9 11:06:56 2017 +0000

    Add missing dg-options to C++11 test.
    
    	* testsuite/30_threads/thread/cons/lwg2097.cc: Compile with
    	-std=gnu++11.

diff --git a/libstdc++-v3/testsuite/30_threads/thread/cons/lwg2097.cc b/libstdc++-v3/testsuite/30_threads/thread/cons/lwg2097.cc
index 3ec4325..d5d6288 100644
--- a/libstdc++-v3/testsuite/30_threads/thread/cons/lwg2097.cc
+++ b/libstdc++-v3/testsuite/30_threads/thread/cons/lwg2097.cc
@@ -1,3 +1,4 @@ 
+// { dg-options "-std=gnu++11" }
 // { dg-do compile }
 // { dg-require-cstdint "" }
 // { dg-require-gthreads "" }