This is the mail archive of the libstdc++@gcc.gnu.org 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: [RFC] std::string(0);


Nathan Myers wrote:

On Fri, Jun 11, 2004 at 07:51:21PM +0200, Daniel Frey wrote:

Martin Sebor wrote:

A conforming implementation is not allowed to reject constructs
such as std::string (0) just because they might cause undefined
behavior at runtime.

OK, so this means we can't go the "easy" way. The remaining options are (AFAICS):


a) Change the standard, make the above example illegal. Unlikely.

b) Ask the compiler folks to detected these cases and emit a warning.


Reporting this usage at compile time would be a valuable service.

The most frequent complaint I've heard is from users who expect it to construct a "null" (i.e., empty) string. AFAIK, that's even the behavior on platforms that let you read from address 0. I would much prefer defining meaningful behavior for it than turning it into an anal retentive error and breaking well-formed programs or implementations. Constructing the empty string is IMO perfectly reasonable, harmless, and has no adverse performance impact over the current behavior (the one if that the requirement is presumably trying to eliminate is there anyway in implementations that throw).

Martin


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