This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC 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: Misreading bool from istringstream


Phil Edwards wrote:
> 
> > i686-pc-linux-gnu g++ 3.0.4: 1#0010
> > i686-pc-linux-gnu g++ 2.95.4: 1#1000
> > sparc-sun-solaris2.7 CC 5.0: 0#0110
> > sparc-sun-solaris2.7 g++ 3.0.4: 1#0010
> > mswin-32 VC++ 6.0: 1#0110
> 
> Huh.  Looks like Sun's CC isn't handling the leading negative.

That's because of 22.2.2.1.2, p14:

    iter_type do_get (iter_type in, iter_type end, ios_base& str,
                      ios_base::iostate& err, bool& val) const;

    -14- Effects: If (str.flags() & ios_base::boolalpha) == 0 then
         input proceeds as it would for a long except that if a value
         is being stored into val, the value is determined according
         to the following:
         If the value to be stored is 0 then false is stored. If the
         value is 1 then true is stored. Otherwise err|=ios_base::failbit
         is performed and no value is stored.

Regards
Martin


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