Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r83162 - in trunk: boost/multiprecision/detail libs/multiprecision/test/compile_fail
From: john_at_[hidden]
Date: 2013-02-26 07:43:15


Author: johnmaddock
Date: 2013-02-26 07:43:14 EST (Tue, 26 Feb 2013)
New Revision: 83162
URL: http://svn.boost.org/trac/boost/changeset/83162

Log:
Change boolean context conversion operator so it's not convertible to void*.
Fixes #8177.
Added:
   trunk/libs/multiprecision/test/compile_fail/conv_fail_59.cpp (contents, props changed)
Text files modified:
   trunk/boost/multiprecision/detail/number_base.hpp | 15 +++++++--------
   1 files changed, 7 insertions(+), 8 deletions(-)

Modified: trunk/boost/multiprecision/detail/number_base.hpp
==============================================================================
--- trunk/boost/multiprecision/detail/number_base.hpp (original)
+++ trunk/boost/multiprecision/detail/number_base.hpp 2013-02-26 07:43:14 EST (Tue, 26 Feb 2013)
@@ -283,13 +283,12 @@
    typedef expression<Tag, Arg1, Arg2, Arg3, Arg4> type;
 };
 
-template <class T>
 struct unmentionable
 {
- static void proc(){}
+ unmentionable* proc(){ return 0; }
 };
 
-typedef void (*unmentionable_type)();
+typedef unmentionable* (unmentionable::*unmentionable_type)();
 
 template <class T>
 struct expression_storage
@@ -334,7 +333,7 @@
    operator unmentionable_type()const
    {
       result_type r(*this);
- return r ? &unmentionable<void>::proc : 0;
+ return r ? &unmentionable::proc : 0;
    }
 
 private:
@@ -357,7 +356,7 @@
 
    operator unmentionable_type()const
    {
- return arg ? &unmentionable<void>::proc : 0;
+ return arg ? &unmentionable::proc : 0;
    }
 
 private:
@@ -386,7 +385,7 @@
    operator unmentionable_type()const
    {
       result_type r(*this);
- return r ? &unmentionable<void>::proc : 0;
+ return r ? &unmentionable::proc : 0;
    }
 
    static const unsigned left_depth = left_type::depth + 1;
@@ -426,7 +425,7 @@
    operator unmentionable_type()const
    {
       result_type r(*this);
- return r ? &unmentionable<void>::proc : 0;
+ return r ? &unmentionable::proc : 0;
    }
 
    static const unsigned left_depth = left_type::depth + 1;
@@ -475,7 +474,7 @@
    operator unmentionable_type()const
    {
       result_type r(*this);
- return r ? &unmentionable<void>::proc : 0;
+ return r ? &unmentionable::proc : 0;
    }
 
    static const unsigned left_depth = left_type::depth + 1;

Added: trunk/libs/multiprecision/test/compile_fail/conv_fail_59.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/multiprecision/test/compile_fail/conv_fail_59.cpp 2013-02-26 07:43:14 EST (Tue, 26 Feb 2013)
@@ -0,0 +1,14 @@
+///////////////////////////////////////////////////////////////////////////////
+// Copyright 2012 John Maddock. Distributed under the Boost
+// Software License, Version 1.0. (See accompanying file
+// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+#include <boost/multiprecision/cpp_int.hpp>
+
+using namespace boost::multiprecision;
+
+int main()
+{
+ cpp_int i(1), j(3);
+ void* p = i * j;
+}


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk