Index: Portfile
===================================================================
--- Portfile	(revision 132095)
+++ Portfile	(working copy)
@@ -76,6 +76,11 @@
 # later.
 patchfiles          yosemite-libtool.patch
 
+# Use this patch when using libc++ only; not needed for libstdc++
+if {${configure.cxx_stdlib} eq "libc++"} {
+    patchfiles-append patch-clang-libcxx.diff
+}
+
 # common configure arguments
 configure.args \
     --disable-dependency-tracking \
@@ -114,9 +119,11 @@
 
 compiler.blacklist-append { clang <= 318.0.61 } macports-clang-2.9
 
-# Block compilers based on llvm-3.5 and later.
+# Block compilers based on llvm-3.5 and later, for now.
 # See also < http://llvm.org/bugs/show_bug.cgi?id=21083 >
 #          < https://trac.macports.org/ticket/45011 >.
+# REMINDER: Check out this patch when using libc++ to
+# see if it works generically.
 
 compiler.blacklist-append {clang >= 600} macports-clang-3.5 macports-clang-3.6
 
@@ -254,6 +261,12 @@
 post-destroot {
     system "echo 'graphics_toolkit(\"gnuplot\");' >> ${destroot}${prefix}/share/octave/site/m/startup/octaverc"
 
+    # Matches "Use this patch when using libc++ only; not needed for libstdc++".
+    if {${configure.cxx_stdlib} eq "libc++"} {
+        xinstall -m 640 ${worksrcpath}/liboctave/operators/libcxx-fix.h \
+            ${destroot}${prefix}/include/${name}-${version}/${name}/libcxx-fix.h
+    }
+
     if {[variant_isset gui]} {
         set appdir ${destroot}${applications_dir}/Octave.app
         xinstall -d ${appdir}/Contents/MacOS
Index: files/patch-clang-libcxx.diff
===================================================================
--- files/patch-clang-libcxx.diff	(revision 0)
+++ files/patch-clang-libcxx.diff	(working copy)
@@ -0,0 +1,105 @@
+# HG changeset patch
+# User Kefu Chai <tchaikov@gmail.com>
+# Date 1413043255 -28800
+#      Sun Oct 12 00:00:55 2014 +0800
+# Node ID 1433cd4f7b7bda0b0e0a04f990b55ffc3cbaf701
+# Parent  91a6f06c505220d269de3a0dab8cc898d03d91a0
+fix the build error on clang 3.5 and libc++ (bug #43298)
+
+* liboctave/operators/mx-inlines.cc:
+use the workaround if libc++ with this issue is detected.
+
+* liboctave/operators/libcxx-fix.cc:
+add a workaround for http://llvm.org/bugs/show_bug.cgi?id=21083, so that only
+the arithmetic types are accepted for the function template "libcxx_fix::pow()".
+
+diff -r 91a6f06c5052 -r 1433cd4f7b7b liboctave/operators/libcxx-fix.h
+--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
++++ liboctave/operators/libcxx-fix.h	Sun Oct 12 00:00:55 2014 +0800
+@@ -0,0 +1,69 @@
++#ifndef _LIBCPP_VERSION
++#error "for libc++ only"
++#endif
++
++namespace libcxx_fix {
++
++using std::is_integral;
++using std::is_same;
++using std::enable_if;
++
++template <class _Tp, class _Tn = void>
++struct numeric_type
++{
++    typedef void type;
++    static const bool value = false;
++};
++
++template <class _Tp>
++struct numeric_type<_Tp, typename enable_if<is_integral<_Tp>::value ||
++                                            is_same<_Tp, double>::value>::type>
++{
++    typedef double type;
++    static const bool value = true;
++};
++
++template <class _Tp>
++struct numeric_type<_Tp, typename enable_if<is_same<_Tp, long double>::value ||
++                                            is_same<_Tp, float>::value>::type>
++{
++    typedef _Tp type;
++    static const bool value = true;
++};
++
++template <>
++struct numeric_type<void, void>
++{
++    static const bool value = true;
++};
++
++template <class _A1, class _A2,
++          bool = numeric_type<_A1>::value &&
++                 numeric_type<_A2>::value>
++class promote
++{};
++
++template <class _A1, class _A2>
++class promote<_A1, _A2, true>
++{
++private:
++    typedef typename numeric_type<_A1>::type __type1;
++    typedef typename numeric_type<_A2>::type __type2;
++public:
++    typedef decltype(__type1() + __type2()) type;
++};
++
++template <class _A1, class _A2>
++inline _LIBCPP_INLINE_VISIBILITY
++typename promote<_A1, _A2>::type
++pow(_A1 __x, _A2 __y) _NOEXCEPT
++{
++    typedef typename promote<_A1, _A2>::type __result_type;
++#if _LIBCPP_STD_VER > 11
++    static_assert((!(is_same<_A1, __result_type>::value &&
++                     is_same<_A2, __result_type>::value)), "");
++#endif
++    return ::pow(static_cast<__result_type>(__x), static_cast<__result_type>(__y));
++}
++
++}
+diff -r 91a6f06c5052 -r 1433cd4f7b7b liboctave/operators/mx-inlines.cc
+--- liboctave/operators/mx-inlines.cc	Thu Oct 09 20:38:04 2014 -0700
++++ liboctave/operators/mx-inlines.cc	Sun Oct 12 00:00:55 2014 +0800
+@@ -306,7 +306,13 @@
+ 
+ // Let the compiler decide which pow to use, whichever best matches the
+ // arguments provided.
++#if defined(_LIBCPP_VERSION) && (_LIBCPP_VERSION >= 1101)
++// Workaround http://llvm.org/bugs/show_bug.cgi?id=21083
++#include "libcxx-fix.h"
++using libcxx_fix::pow;
++#else
+ using std::pow;
++#endif
+ DEFMXMAPPER2X (mx_inline_pow, pow)
+ 
+ // Arbitrary function appliers. The function is a template parameter to enable
