This is the mail archive of the
mailing list for the libstdc++ project.
Re: [patch] Remove invalid test on non-const empty strings
- From: Paolo Carlini <pcarlini at suse dot de>
- To: Chris Jefferson <caj at cs dot york dot ac dot uk>
- Cc: libstdc++ <libstdc++ at gcc dot gnu dot org>
- Date: Fri, 21 Jan 2005 01:16:37 +0100
- Subject: Re: [patch] Remove invalid test on non-const empty strings
- References: <41F01164.firstname.lastname@example.org>
Chris Jefferson wrote:
As we are testing empty strings, size()==0. Therefore we can only
perform the operation "s" where s is the empty string when s is
const (when s will return charT()). When s is non-const the
operation is undefined. The test tries to access s on an empty
string s on both const and non-const strings. Therefore this patch
fixes things up.
I see your point, but I think the issue is somewhat debatable, and much
more general, actually. In this sense: according to 21.3.4, as you point
out above, "the behavior is undefined". Now, it happens, that, *given
our current implementation*, if things are not broken, we mus return
'\0' in this case too.
Therefore, the general issue is the following: should our testsuite only
test what the standard mandates or, when appropriate, request, so to
speak, "more" from the code, for instance specific behaviors when the
behavior is strictly speaking undefined? I don't think we have a very
rigorous policy about this issue and, frankly, being an implementor that
cares about *regressions* and *unexpected* changes of behavior, that is
not being a seller of a "conformancy testsuite", I think the latter
interpretation has its own advantages, in some cases.
What do other people think?