[ https://issues.apache.org/jira/browse/STDCXX-1061?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13204044#comment-13204044 ]
Travis Vitek edited comment on STDCXX-1061 at 2/8/12 10:04 PM: --------------------------------------------------------------- Committed as [r1242128|http://svn.apache.org/viewvc?view=revision&revision=1242128]. was (Author: vitek): Comitted as [r1242128|http://svn.apache.org/viewvc?view=revision&revision=1242128]. > std::valarray<>::operator&& () produces wrong result > ---------------------------------------------------- > > Key: STDCXX-1061 > URL: https://issues.apache.org/jira/browse/STDCXX-1061 > Project: C++ Standard Library > Issue Type: Bug > Components: 23. Containers > Affects Versions: 4.2.1 > Environment: Solaris 10 and 11 > Red Hat Linux > OpenSuSE Linux > SunPro C++ 12.1, 12.2, 12.3 > Defect is independent of platform and/or compiler. > Reporter: Stefan Teleman > Assignee: Travis Vitek > Labels: conformance, standards > Fix For: 4.2.x, 4.3.x, 5.0.0 > > Attachments: stdcxx-1061.patch > > > std::valarray<>::operator&& () produces wrong result: > {code:title=test.cc|borderStyle=solid} > #include <iostream> > #include <valarray> > static const size_t maxlen = 10; > void print(const std::valarray<bool>& v) > { > for (size_t i = 0; i < maxlen; ++i) > std::cerr << v[i] << " "; > std::cerr << std::endl; > } > int main() > { > int nonzero[maxlen] = { 0, 1, 0, 3, 0, -5, 0, -7, 0, -11 }; > int one = 1; > int ret = 0; > size_t i; > std::valarray<int> v0 (nonzero, maxlen); > std::valarray<bool> v3 (maxlen); > for (i = 0; i < maxlen; i++) > v3[i] = nonzero[i] && one; > std::valarray<bool> v1 = std::operator&& (v0, one); > for (i = 0; i < maxlen; i++) > { > if ((nonzero[i] && one) != v1[i]) > ret = 1; > } > if (ret) > { > std::cerr << "expected: "; > print (v3); > std::cerr << "got: "; > print (v1); > } > return ret; > } > {code} > 1. Output from GCC 4.5.0: > {noformat} > [steleman@darthvader][/src/steleman/programming/stdcxx-ss122/bugfixes-sunw/nothrow][02/08/2012 > 13:22:47][2463]>> ./v-gcc > [steleman@darthvader][/src/steleman/programming/stdcxx-ss122/bugfixes-sunw/nothrow][02/08/2012 > 13:23:01][2464]>> echo $status > 0 > {noformat} > 2. Output from SunPro C++ 12.2 with stlport4: > {noformat} > [steleman@darthvader][/src/steleman/programming/stdcxx-ss122/bugfixes-sunw/nothrow][02/08/2012 > 13:23:02][2465]>> ./v-ss122-stlport > [steleman@darthvader][/src/steleman/programming/stdcxx-ss122/bugfixes-sunw/nothrow][02/08/2012 > 13:23:08][2466]>> echo $status > 0 > {noformat} > 3. Output from SunPro C++ 12.2 with our patched stdcxx: > {noformat} > [steleman@darthvader][/src/steleman/programming/stdcxx-ss122/bugfixes-sunw/nothrow][02/08/2012 > 13:23:10][2467]>> ./v-ss122-stdcxx > [steleman@darthvader][/src/steleman/programming/stdcxx-ss122/bugfixes-sunw/nothrow][02/08/2012 > 13:23:18][2468]>> echo $status > 0 > {noformat} > 4. Output from Pathscale 4.0.12.1 (which didn't patch stdcxx): > {noformat} > [steleman@darthvader][/src/steleman/programming/stdcxx-ss122/bugfixes-sunw/nothrow][02/08/2012 > 13:23:20][2469]>> ./v-pathscale > expected: 0 1 0 1 0 1 0 1 0 1 > got: 0 1 0 0 0 0 0 0 0 0 > [steleman@darthvader][/src/steleman/programming/stdcxx-ss122/bugfixes-sunw/nothrow][02/08/2012 > 13:23:24][2470]>> echo $status > 1 > {noformat} > Patch for stdcxx 4.2.1 to follow shortly. -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa For more information on JIRA, see: http://www.atlassian.com/software/jira