This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] LWG 3050 Fix cv-qualification of convertibility constraints


On 18/06/18 19:00 +0100, Jonathan Wakely wrote:
This issue hasn't been voted into the working draft yet, but it's been
approved by LWG and is obviously correct.

	* include/std/chrono (duration, operator*, operator/, operator%): Use
	const-qualified type as source type in is_convertible constraints.
	* testsuite/20_util/duration/arithmetic/dr3050.cc: New.

I forgot to 'git add' this new test. Here it is.

Tested x86_64-linux, committed to trunk.

commit 89ea69b95205a1cfadee6599f2168bc077f57fb7
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Tue Jun 19 22:06:56 2018 +0100

    Add testcase accidentally not committed earlier
    
            * testsuite/20_util/duration/arithmetic/dr3050.cc: Add new test
            missed from recent commit.

diff --git a/libstdc++-v3/testsuite/20_util/duration/arithmetic/dr3050.cc b/libstdc++-v3/testsuite/20_util/duration/arithmetic/dr3050.cc
new file mode 100644
index 00000000000..a2d26620466
--- /dev/null
+++ b/libstdc++-v3/testsuite/20_util/duration/arithmetic/dr3050.cc
@@ -0,0 +1,30 @@
+// Copyright (C) 2018 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library.  This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3.  If not see
+// <http://www.gnu.org/licenses/>.
+
+// { dg-do compile { target c++11 } }
+
+#include <chrono>
+
+struct X { operator int64_t() /* not const */; };
+
+void test01(std::chrono::seconds s, X x)
+{
+  s * x; // { dg-error "no match" }
+  x * s; // { dg-error "no match" }
+  s / x; // { dg-error "no match" }
+  s % x; // { dg-error "no match" }
+}

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]