incubator-stdcxx-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Farid Zaripov (JIRA)" <j...@apache.org>
Subject [jira] Commented: (STDCXX-206) std::operator<<(ostream, string) doesn't call width(0) on ios_base::failure
Date Tue, 09 Oct 2007 13:15:51 GMT

    [ https://issues.apache.org/jira/browse/STDCXX-206?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12533360
] 

Farid Zaripov commented on STDCXX-206:
--------------------------------------

I think that in r420970 should be used #ifdef instead of #ifndef (from changelog: When the
macro is not #defined, reset width only after all characters, including any padding, have
been successfully output (for consistency with numeric inserters)).

The patch below:

Index: _ioinsert.cc
===================================================================
--- _ioinsert.cc	(revision 582748)
+++ _ioinsert.cc	(working copy)
@@ -170,7 +170,7 @@
             else {
                 __err = _STD::ios_base::badbit;
 
-#ifndef _RWSTD_NO_EXT_KEEP_WIDTH_ON_FAILURE
+#ifdef _RWSTD_NO_EXT_KEEP_WIDTH_ON_FAILURE
                 __strm.width (0);
 #endif   // _RWSTD_NO_EXT_KEEP_WIDTH_ON_FAILURE
             }


> std::operator<<(ostream, string) doesn't call width(0) on ios_base::failure
> ---------------------------------------------------------------------------
>
>                 Key: STDCXX-206
>                 URL: https://issues.apache.org/jira/browse/STDCXX-206
>             Project: C++ Standard Library
>          Issue Type: Bug
>          Components: 21. Strings
>    Affects Versions: 4.1.3
>         Environment: all
>            Reporter: Anton Pevtsov
>            Assignee: Martin Sebor
>            Priority: Minor
>             Fix For: 4.2
>
>
> The following test fails:
> #include <iostream>
> #include <strstream>
> #include <string>
> #include <cassert>
> int main(int argc, char* argv[])
> {
>     std::string str ("abcdefghijk");
>     char buf[10];
>     std::ostrstream os (buf, sizeof(buf));
>     const std::streamsize width = 2;
>     os.width (width);
>     os.exceptions (std::ios_base::failbit | std::ios_base::badbit);
>     try {
>         os << str;
>     }
>     catch (std::ios_base::failure&) {
>     }
>     assert (0 == os.width ());
>     return 0;
> }

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message