public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/50661] New: std::equal should use more efficient version for arrays of pointers
@ 2011-10-07 23:16 emil at wojak dot eu
  2011-10-07 23:48 ` [Bug libstdc++/50661] " paolo.carlini at oracle dot com
                   ` (23 more replies)
  0 siblings, 24 replies; 25+ messages in thread
From: emil at wojak dot eu @ 2011-10-07 23:16 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50661

             Bug #: 50661
           Summary: std::equal should use more efficient version for
                    arrays of pointers
    Classification: Unclassified
           Product: gcc
           Version: 4.4.5
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: P3
         Component: libstdc++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: emil@wojak.eu


The following program uses the generic comparison algorithm in
bits/stl_algobase.h, while it could use the template specialization using
__builtin_memcmp instead.

#include <iostream>
#include <boost/array.hpp>

int main() {
        boost::array<void*, 888> a, b; 

        bool res = std::equal(a.begin(), a.begin() + 50, b.begin());

        return 0;
}

I checked with gcc-4.4.5, but I saw it's the same in SVN trunk.
The following patch solves this issue.

--- /usr/lib/gcc/i686-pc-linux-gnu/4.4.5/include/g++-v4/bits/stl_algobase.h    
2011-09-07 16:34:35.581681814 +0200
+++ /usr/lib/gcc/i686-pc-linux-gnu/4.4.5/include/g++-v4/bits/stl_algobase.h    
 2011-10-08 01:09:44.987380358 +0200
@@ -823,7 +823,7 @@
     {
       typedef typename iterator_traits<_II1>::value_type _ValueType1;
       typedef typename iterator_traits<_II2>::value_type _ValueType2;
-      const bool __simple = (__is_integer<_ValueType1>::__value
+      const bool __simple = ((__is_integer<_ValueType1>::__value ||
__is_pointer<_ValueType1>::__value)
                             && __is_pointer<_II1>::__value
                             && __is_pointer<_II2>::__value
                             && __are_same<_ValueType1, _ValueType2>::__value);


^ permalink raw reply	[flat|nested] 25+ messages in thread

end of thread, other threads:[~2011-10-11 19:11 UTC | newest]

Thread overview: 25+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-10-07 23:16 [Bug libstdc++/50661] New: std::equal should use more efficient version for arrays of pointers emil at wojak dot eu
2011-10-07 23:48 ` [Bug libstdc++/50661] " paolo.carlini at oracle dot com
2011-10-08  7:36 ` jakub at gcc dot gnu.org
2011-10-08  8:13 ` paolo.carlini at oracle dot com
2011-10-08  8:51 ` marc.glisse at normalesup dot org
2011-10-08  9:28 ` paolo.carlini at oracle dot com
2011-10-08 11:00 ` marc.glisse at normalesup dot org
2011-10-08 11:19 ` paolo.carlini at oracle dot com
2011-10-08 11:35 ` jakub at gcc dot gnu.org
2011-10-08 11:44 ` paolo.carlini at oracle dot com
2011-10-08 11:57 ` paolo.carlini at oracle dot com
2011-10-08 12:22 ` jakub at gcc dot gnu.org
2011-10-08 12:58 ` paolo.carlini at oracle dot com
2011-10-08 13:10 ` jakub at gcc dot gnu.org
2011-10-08 13:49 ` vincenzo.innocente at cern dot ch
2011-10-11 11:05 ` paolo.carlini at oracle dot com
2011-10-11 11:42 ` krebbel at gcc dot gnu.org
2011-10-11 11:55 ` paolo.carlini at oracle dot com
2011-10-11 12:04 ` bernds at gcc dot gnu.org
2011-10-11 12:10 ` paolo.carlini at oracle dot com
2011-10-11 12:40 ` paolo.carlini at oracle dot com
2011-10-11 12:41 ` paolo at gcc dot gnu.org
2011-10-11 16:13 ` vincenzo.innocente at cern dot ch
2011-10-11 19:02 ` pcarlini at gmail dot com
2011-10-11 19:11 ` paolo.carlini at oracle dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).