[LLVMbugs] [Bug 11909] New: Incorrect error generated for a valid <valarray> case

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Thu Feb 2 12:16:52 PST 2012


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

             Bug #: 11909
           Summary: Incorrect error generated for a valid <valarray> case
           Product: clang
           Version: 3.0
          Platform: Macintosh
        OS/Version: MacOS X
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Headers
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: christopher at lord.ac
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified


Just looked into this in our compiler, and noticed clang suffers the same
problem:

    # clang -v
    Apple clang version 2.1 (tags/Apple/clang-163.7.1) (based on LLVM 3.0svn)
    Target: x86_64-apple-darwin11.2.0
    Thread model: posix


The following case:

    #include <valarray>
    using namespace std;
    int main() {
       valarray<int> y0(4, 3);
       valarray<bool> res(2 == y0);
       return 0;
    }

fails with error:


    # clang t.cpp
    In file included from t.cpp:1:
    /usr/include/c++/4.2.1/valarray:1027:1: error: no viable conversion from
'_Expr<_Closure, int>' to
          '_Expr<_BinClos<std::__equal_to, _Constant, _ValArray, int, int>,
typename __fun<__equal_to,
          int>::result_type>'
    _DEFINE_BINARY_OPERATOR(==, __equal_to)
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    /usr/include/c++/4.2.1/valarray:1012:14: note: instantiated from:
          return _Expr<_Closure, _Tp>(_Closure(__t, __v));                  \
                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    t.cpp:5:25: note: in instantiation of function template specialization
'std::operator==<int>' requested
          here
       valarray<bool> res(2 == y0);
                            ^
    /usr/include/c++/4.2.1/bits/valarray_after.h:164:11: note: candidate
constructor
          (the implicit copy constructor) not viable: no known conversion from
'_Expr<_Closure, int>' to 'const
          std::_Expr<std::_BinClos<std::__equal_to, _Constant, _ValArray, int,
int>, bool> &' for 1st argument
        class _Expr
              ^
    /usr/include/c++/4.2.1/bits/valarray_after.h:169:7: note: candidate
constructor not viable: no known
          conversion from '_Expr<_Closure, int>' to 'const
std::_BinClos<std::__equal_to, _Constant, _ValArray,
          int, int> &' for 1st argument
          _Expr(const _Clos&);
          ^

reversing the arguments of operator==() makes the case pass.


    #include <valarray>
    using namespace std;
    int main() {
       valarray<int> y0(4, 3);
       valarray<bool> res(y0 == 2); // ok!
       return 0;
    }

Opening against headers since that's where it went in our case.

-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.



More information about the llvm-bugs mailing list