Library bug - Problem with string(string::reverse_iterator, string::reverse_iterator)

Gabriel Dos Reis gdr@codesourcery.com
Tue Jun 4 07:10:00 GMT 2002


Paolo Carlini <pcarlini@unitus.it> writes:

| Hi all, hi Benjamin,
| 
| indeed I could reproduce the produce and I'm convinced it is regression 
| wrt 3.0.4 which must be fixed ASAP.
| 
| I could also confirm that the problem is due to this check:
| 
|     // NB: Not required, but considered best practice.
|     if (__builtin_expect(__beg == _InIter(0), 0))
                                    ^^^^^^^^^^

I think Benjamin wanted to say

   __beg == _InIter()

Patch pre-approved for both mainline and branch.

[...]

| Benjamin, could you possibly explain to me a bit the structure of that 
| kind of check? We should find a way to modify it to work well also with 
| reverse_iterator, IMO.

The sanity check is there to catch non-sensical data; since that isn't
exptected to happen frequently it was suggested to use the
__builtin_expect() to instruct the optimizer to do its best about that
check. 

-- Gaby



More information about the Libstdc++ mailing list