This is the mail archive of the mailing list for the libstdc++ project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [patch] Remove invalid test on non-const empty strings

Paolo Carlini wrote:
Chris Jefferson wrote:

As we are testing empty strings, size()==0. Therefore we can only perform the operation "s[0]" where s is the empty string when s is const (when s[0] will return charT()). When s is non-const the operation is undefined. The test tries to access s[0] 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.

Mark Mitchell
CodeSourcery, LLC
(916) 791-8304

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]