This is the mail archive of the
mailing list for the libstdc++ project.
Re: [patch] Remove invalid test on non-const empty strings
- From: Mark Mitchell <mark at codesourcery dot com>
- To: Paolo Carlini <pcarlini at suse dot de>
- Cc: Chris Jefferson <caj at cs dot york dot ac dot uk>, libstdc++ <libstdc++ at gcc dot gnu dot org>
- Date: Thu, 20 Jan 2005 18:11:14 -0800
- Subject: Re: [patch] Remove invalid test on non-const empty strings
- Organization: CodeSourcery, LLC
- References: <41F01164.email@example.com> <41F049E5.firstname.lastname@example.org>
Paolo Carlini wrote:
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 think the tests should test whatever it is that we want V3 to do. If
we intend for it to go beyond the standard in some respect, then testing
that it does indeed do that makes perfect sense.