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: Silently passing wrong input for good one


Hi Martin,

> FWIW, the scanf() behavior isn't quite so rosy :)
>
> The AIX implementation of sscanf() fails on "-3e-abcd" (although
> scanf(), at least in unbuffered mode, behaves close to what you
> describe).
>
> Some of the other implementations of scanf() I tried (e.g., Solaris)
> extract "-3" but leave the "e-abcd" part on the stream. Others (such
> as HP-UX or Linux), extract all of "-3e-" with no error and assign
> -3.

Well, thanks for the plethora of details. A couple of punctualizations:

1- As you may easily imagine, for us is an high priority consistency
with glibc's "interpretation" of scanf, more than other libc
implementations. Which, anyway, I consider pretty right at least as far
as the C++ "as if" behavior is concerned: it returns 1 and assigns the
value. All the implementations you mentioned agree about that.

2- On the C++ front of the issue, there are the specific constraints due
to the fact that the facet gets an input_iterator. I think this easily
rules out many forms of "backtracking" (i.e., the returned iterator
pointing to 'e').

Paolo.


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