[Patch] Fix the narrow/widen problem in money_get::do_get

Martin Sebor sebor@roguewave.com
Thu Feb 26 19:03:00 GMT 2004


Nathan Myers wrote:
> On Thu, Feb 26, 2004 at 07:23:43PM +0100, Paolo Carlini wrote:
> 
>>this is the last missing bit of work, actually for a bug: the
>>standard is pretty clear that ctype::widen must be used in do_get,
>>not ctype::narrow (see 22.2.6.1.2, p4 and note 237).
>>
>>Interestingly, overall, the performance are not affected negatively,
> 
> 
> I should hope so.  The purpose of that fillip (if I have identified it
> correctly, from memory) was specifically to permit optimization.  Note 
> that there has been some effort in committee to forbid it, because the 
> commercial vendors hadn't exploited the opportunity, and (apparently) 
> didn't want competition from anyone who had.

As I said on the reflector the last time we discussed the issue,
an efficient but mainly simpler implementation is possible (and
exists -- ours) that calls narrow(), not widen(). Additionally,
as I also pointed out in the past, the requirement Paolo refers
to above is unimplementable for any specialization of these
facets other than on char and wchar_t, and implementations that
follow it only violate the standard in another area.

> 
> I'm happy to see that this opportunity has finally begun to be
> exploited.  Go Free Software!  Now that an implementation does 
> exploit it, it should be much harder to justify forbidding it.

I am not happy about this approach. The proper way to deal with
this is by fixing the standard first, not by implementing something
that still fails to conform yet is detectably different from every
other implementation out there (and using it later as an argument
to exert pressure in the committee).

Martin



More information about the Libstdc++ mailing list