[LLVMbugs] [Bug 21083] New: SFINAE in <cmath> not doing its job

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Fri Sep 26 12:34:04 PDT 2014


http://llvm.org/bugs/show_bug.cgi?id=21083

            Bug ID: 21083
           Summary: SFINAE in <cmath> not doing its job
           Product: libc++
           Version: unspecified
          Hardware: All
                OS: Solaris
            Status: NEW
          Severity: normal
          Priority: P
         Component: All Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: kaballo86 at hotmail.com
                CC: llvmbugs at cs.uiuc.edu, mclow.lists at gmail.com
    Classification: Unclassified

JordiGH at ##c++ reported a regression in 3.5 and afterwards, that boils down
to this:

    #include <cmath>
    #include <type_traits>

    struct foo : std::true_type // for ADL
    {
      operator double() const { return 0; }
      operator float() const { return 0; }
    };

    foo pow(foo, int){ return {}; }

    int main() {
      pow(foo{}, 5); // error: call to '__test' is ambiguous at
type_traits:1195
    }

This is due to the `enable_if` in the generic overload of `std::pow` (as well
as others in that header):

    template <class _A1, class _A2>
    inline _LIBCPP_INLINE_VISIBILITY
    typename enable_if
    <
        is_arithmetic<_A1>::value &&
        is_arithmetic<_A2>::value,
        typename __promote<_A1, _A2>::type
    >::type
    pow(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT

Note that `_promote<_A1, _A2>` is instantiated regardless of whether `_A1` and
`_A2` are arithmetic, which results in the ambiguous overload error.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20140926/9865f057/attachment.html>


More information about the llvm-bugs mailing list