aboutsummaryrefslogtreecommitdiff
path: root/libstdc++-v3
diff options
context:
space:
mode:
authorPaolo Carlini <paolo.carlini@oracle.com>2009-10-27 01:18:10 +0000
committerPaolo Carlini <paolo@gcc.gnu.org>2009-10-27 01:18:10 +0000
commit9c67ec2204d7db5ad689b2b4728c8816bbbe6c3e (patch)
tree75e7269d87caf39cfd55bcf8003ba5f6113e0c32 /libstdc++-v3
parent42302b858269b8de1a2b0ec41001e28a9312d439 (diff)
downloadgcc-9c67ec2204d7db5ad689b2b4728c8816bbbe6c3e.zip
gcc-9c67ec2204d7db5ad689b2b4728c8816bbbe6c3e.tar.gz
gcc-9c67ec2204d7db5ad689b2b4728c8816bbbe6c3e.tar.bz2
chrono (duration<>::duration(const duration<>&)): Fix per the straightforward resolution of DR 974.
2009-10-26 Paolo Carlini <paolo.carlini@oracle.com> * include/std/chrono (duration<>::duration(const duration<>&)): Fix per the straightforward resolution of DR 974. * testsuite/20_util/duration/cons/dr974.cc: Add. From-SVN: r153581
Diffstat (limited to 'libstdc++-v3')
-rw-r--r--libstdc++-v3/ChangeLog6
-rw-r--r--libstdc++-v3/include/std/chrono3
-rw-r--r--libstdc++-v3/testsuite/20_util/duration/cons/dr974.cc37
3 files changed, 45 insertions, 1 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index b09257e..daeb439 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -1,3 +1,9 @@
+2009-10-26 Paolo Carlini <paolo.carlini@oracle.com>
+
+ * include/std/chrono (duration<>::duration(const duration<>&)): Fix
+ per the straightforward resolution of DR 974.
+ * testsuite/20_util/duration/cons/dr974.cc: Add.
+
2009-10-26 Jakub Jelinek <jakub@redhat.com>
PR libstdc++/38923
diff --git a/libstdc++-v3/include/std/chrono b/libstdc++-v3/include/std/chrono
index aa4888d..300c13c 100644
--- a/libstdc++-v3/include/std/chrono
+++ b/libstdc++-v3/include/std/chrono
@@ -225,7 +225,8 @@ namespace std
: __r(duration_cast<duration>(__d).count())
{
static_assert(treat_as_floating_point<rep>::value == true
- || ratio_divide<_Period2, period>::type::den == 1,
+ || (ratio_divide<_Period2, period>::type::den == 1
+ && !treat_as_floating_point<_Rep2>::value),
"the resulting duration is not exactly representable");
}
diff --git a/libstdc++-v3/testsuite/20_util/duration/cons/dr974.cc b/libstdc++-v3/testsuite/20_util/duration/cons/dr974.cc
new file mode 100644
index 0000000..43132c9
--- /dev/null
+++ b/libstdc++-v3/testsuite/20_util/duration/cons/dr974.cc
@@ -0,0 +1,37 @@
+// { dg-do compile }
+// { dg-options "-std=gnu++0x" }
+// { dg-require-cstdint "" }
+
+// Copyright (C) 2009 Free Software Foundation
+//
+// 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/>.
+
+// 20.8.3.1 duration constructors [time.duration.cons]
+
+#include <chrono>
+
+// DR 974.
+void test01()
+{
+ using namespace std::chrono;
+
+ duration<double> d(3.5);
+ duration<int> i = d; // implicit truncation, should not compile
+}
+
+// { dg-error "instantiated from here" "" { target *-*-* } 32 }
+// { dg-error "not exactly representable" "" { target *-*-* } 227 }
+// { dg-excess-errors "In instantiation of" }