You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@stdcxx.apache.org by "Mark Brown (JIRA)" <ji...@apache.org> on 2007/02/02 23:45:05 UTC

[jira] Created: (STDCXX-333) std::wfilebuf extracts more than 1 character from a 1 byte file

std::wfilebuf extracts more than 1 character from a 1 byte file
---------------------------------------------------------------

                 Key: STDCXX-333
                 URL: https://issues.apache.org/jira/browse/STDCXX-333
             Project: C++ Standard Library
          Issue Type: Bug
          Components: 27. Input/Output
    Affects Versions: 4.1.3
         Environment: gcc 3.2.3 on Linux
            Reporter: Mark Brown


I get an an abort when I run the following program on Linux.

#include <cassert>
#include <fstream>
#include <iostream>

int main ()
{
    {
        std::filebuf fb;
        fb.open ("file", std::ios::out);
        fb.sputc ('a');
    }

    std::wfilebuf fb;
    fb.pubimbue (std::locale ("en_US.UTF-8"));
    fb.open ("file", std::ios::in);

    const int c[] = { fb.sbumpc (), fb.sgetc () };
    std::cout << c [0] << ' ' << c [1] << std::endl;

    assert (L'a' == c [0]);
    assert (std::wfilebuf::traits_type::eof () == c [1]);
}

test: test.cpp:21: int main(): Assertion `std::wfilebuf::traits_type::eof () == c [1]' failed.
Aborted


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


[jira] Updated: (STDCXX-333) [gcc 3.2.3/Linux] std::wfilebuf extracts more than 1 character from a 1 byte file

Posted by "Martin Sebor (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/STDCXX-333?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Martin Sebor updated STDCXX-333:
--------------------------------

    Summary: [gcc 3.2.3/Linux] std::wfilebuf extracts more than 1 character from a 1 byte file  (was: Linux] std::wfilebuf extracts more than 1 character from a 1 byte file)

> [gcc 3.2.3/Linux] std::wfilebuf extracts more than 1 character from a 1 byte file
> ---------------------------------------------------------------------------------
>
>                 Key: STDCXX-333
>                 URL: https://issues.apache.org/jira/browse/STDCXX-333
>             Project: C++ Standard Library
>          Issue Type: Bug
>          Components: 27. Input/Output
>    Affects Versions: 4.1.3
>         Environment: gcc 3.2.3 on Linux
>            Reporter: Mark Brown
>            Assignee: Martin Sebor
>            Priority: Minor
>
> I get an an abort when I run the following program on Linux.
> #include <cassert>
> #include <fstream>
> #include <iostream>
> int main ()
> {
>     {
>         std::filebuf fb;
>         fb.open ("file", std::ios::out);
>         fb.sputc ('a');
>     }
>     std::wfilebuf fb;
>     fb.pubimbue (std::locale ("en_US.UTF-8"));
>     fb.open ("file", std::ios::in);
>     const int c[] = { fb.sbumpc (), fb.sgetc () };
>     std::cout << c [0] << ' ' << c [1] << std::endl;
>     assert (L'a' == c [0]);
>     assert (std::wfilebuf::traits_type::eof () == c [1]);
> }
> test: test.cpp:21: int main(): Assertion `std::wfilebuf::traits_type::eof () == c [1]' failed.
> Aborted

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


[jira] Updated: (STDCXX-333) Linux] std::wfilebuf extracts more than 1 character from a 1 byte file

Posted by "Martin Sebor (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/STDCXX-333?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Martin Sebor updated STDCXX-333:
--------------------------------

    Priority: Minor  (was: Major)
     Summary: Linux] std::wfilebuf extracts more than 1 character from a 1 byte file  (was: std::wfilebuf extracts more than 1 character from a 1 byte file)

This is specific to Linux (couldn't reproduce on Cygwin or Solaris).

> Linux] std::wfilebuf extracts more than 1 character from a 1 byte file
> ----------------------------------------------------------------------
>
>                 Key: STDCXX-333
>                 URL: https://issues.apache.org/jira/browse/STDCXX-333
>             Project: C++ Standard Library
>          Issue Type: Bug
>          Components: 27. Input/Output
>    Affects Versions: 4.1.3
>         Environment: gcc 3.2.3 on Linux
>            Reporter: Mark Brown
>            Priority: Minor
>
> I get an an abort when I run the following program on Linux.
> #include <cassert>
> #include <fstream>
> #include <iostream>
> int main ()
> {
>     {
>         std::filebuf fb;
>         fb.open ("file", std::ios::out);
>         fb.sputc ('a');
>     }
>     std::wfilebuf fb;
>     fb.pubimbue (std::locale ("en_US.UTF-8"));
>     fb.open ("file", std::ios::in);
>     const int c[] = { fb.sbumpc (), fb.sgetc () };
>     std::cout << c [0] << ' ' << c [1] << std::endl;
>     assert (L'a' == c [0]);
>     assert (std::wfilebuf::traits_type::eof () == c [1]);
> }
> test: test.cpp:21: int main(): Assertion `std::wfilebuf::traits_type::eof () == c [1]' failed.
> Aborted

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


[jira] Updated: (STDCXX-333) [gcc 3.2.3/Linux] std::wfilebuf extracts more than 1 character from a 1 byte file

Posted by "Martin Sebor (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/STDCXX-333?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Martin Sebor updated STDCXX-333:
--------------------------------

    Severity: Incorrect Behavior

Set Severity to Incorrect Behavior.

> [gcc 3.2.3/Linux] std::wfilebuf extracts more than 1 character from a 1 byte file
> ---------------------------------------------------------------------------------
>
>                 Key: STDCXX-333
>                 URL: https://issues.apache.org/jira/browse/STDCXX-333
>             Project: C++ Standard Library
>          Issue Type: Bug
>          Components: 27. Input/Output
>    Affects Versions: 4.1.3
>         Environment: gcc 3.2.3 on Linux
>            Reporter: Mark Brown
>            Assignee: Martin Sebor
>            Priority: Minor
>
> I get an an abort when I run the following program on Linux.
> #include <cassert>
> #include <fstream>
> #include <iostream>
> int main ()
> {
>     {
>         std::filebuf fb;
>         fb.open ("file", std::ios::out);
>         fb.sputc ('a');
>     }
>     std::wfilebuf fb;
>     fb.pubimbue (std::locale ("en_US.UTF-8"));
>     fb.open ("file", std::ios::in);
>     const int c[] = { fb.sbumpc (), fb.sgetc () };
>     std::cout << c [0] << ' ' << c [1] << std::endl;
>     assert (L'a' == c [0]);
>     assert (std::wfilebuf::traits_type::eof () == c [1]);
> }
> test: test.cpp:21: int main(): Assertion `std::wfilebuf::traits_type::eof () == c [1]' failed.
> Aborted

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


[jira] Commented: (STDCXX-333) Linux] std::wfilebuf extracts more than 1 character from a 1 byte file

Posted by "Martin Sebor (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/STDCXX-333?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12501031 ] 

Martin Sebor commented on STDCXX-333:
-------------------------------------

Reproduced reliably with gcc 4.1.1 on Linux/x86_64.

> Linux] std::wfilebuf extracts more than 1 character from a 1 byte file
> ----------------------------------------------------------------------
>
>                 Key: STDCXX-333
>                 URL: https://issues.apache.org/jira/browse/STDCXX-333
>             Project: C++ Standard Library
>          Issue Type: Bug
>          Components: 27. Input/Output
>    Affects Versions: 4.1.3
>         Environment: gcc 3.2.3 on Linux
>            Reporter: Mark Brown
>            Priority: Minor
>
> I get an an abort when I run the following program on Linux.
> #include <cassert>
> #include <fstream>
> #include <iostream>
> int main ()
> {
>     {
>         std::filebuf fb;
>         fb.open ("file", std::ios::out);
>         fb.sputc ('a');
>     }
>     std::wfilebuf fb;
>     fb.pubimbue (std::locale ("en_US.UTF-8"));
>     fb.open ("file", std::ios::in);
>     const int c[] = { fb.sbumpc (), fb.sgetc () };
>     std::cout << c [0] << ' ' << c [1] << std::endl;
>     assert (L'a' == c [0]);
>     assert (std::wfilebuf::traits_type::eof () == c [1]);
> }
> test: test.cpp:21: int main(): Assertion `std::wfilebuf::traits_type::eof () == c [1]' failed.
> Aborted

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


[jira] Commented: (STDCXX-333) [gcc 3.2.3/Linux] std::wfilebuf extracts more than 1 character from a 1 byte file

Posted by "Martin Sebor (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/STDCXX-333?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12551999 ] 

Martin Sebor commented on STDCXX-333:
-------------------------------------

Couldn't reproduce with gcc 3.2.3-56 (tried 15s and 15S) on Red Hat EL 3 (Taroon Update 8) but reproduced it in a 15D buiold with gcc 4.1.0 on SuSE 10.0.

Next time though, before chasing this down, look at STDCXX-435 first!


> [gcc 3.2.3/Linux] std::wfilebuf extracts more than 1 character from a 1 byte file
> ---------------------------------------------------------------------------------
>
>                 Key: STDCXX-333
>                 URL: https://issues.apache.org/jira/browse/STDCXX-333
>             Project: C++ Standard Library
>          Issue Type: Bug
>          Components: 27. Input/Output
>    Affects Versions: 4.1.3
>         Environment: gcc 3.2.3 on Linux
>            Reporter: Mark Brown
>            Assignee: Martin Sebor
>            Priority: Minor
>
> I get an an abort when I run the following program on Linux.
> #include <cassert>
> #include <fstream>
> #include <iostream>
> int main ()
> {
>     {
>         std::filebuf fb;
>         fb.open ("file", std::ios::out);
>         fb.sputc ('a');
>     }
>     std::wfilebuf fb;
>     fb.pubimbue (std::locale ("en_US.UTF-8"));
>     fb.open ("file", std::ios::in);
>     const int c[] = { fb.sbumpc (), fb.sgetc () };
>     std::cout << c [0] << ' ' << c [1] << std::endl;
>     assert (L'a' == c [0]);
>     assert (std::wfilebuf::traits_type::eof () == c [1]);
> }
> test: test.cpp:21: int main(): Assertion `std::wfilebuf::traits_type::eof () == c [1]' failed.
> Aborted

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


[jira] Updated: (STDCXX-333) [gcc 3.2.3/Linux] std::wfilebuf extracts more than 1 character from a 1 byte file

Posted by "Martin Sebor (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/STDCXX-333?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Martin Sebor updated STDCXX-333:
--------------------------------


I can't reproduce this with gcc 4.1.2 on Fedora Core 6, x86.

> [gcc 3.2.3/Linux] std::wfilebuf extracts more than 1 character from a 1 byte file
> ---------------------------------------------------------------------------------
>
>                 Key: STDCXX-333
>                 URL: https://issues.apache.org/jira/browse/STDCXX-333
>             Project: C++ Standard Library
>          Issue Type: Bug
>          Components: 27. Input/Output
>    Affects Versions: 4.1.3
>         Environment: gcc 3.2.3 on Linux
>            Reporter: Mark Brown
>            Assignee: Martin Sebor
>            Priority: Minor
>
> I get an an abort when I run the following program on Linux.
> #include <cassert>
> #include <fstream>
> #include <iostream>
> int main ()
> {
>     {
>         std::filebuf fb;
>         fb.open ("file", std::ios::out);
>         fb.sputc ('a');
>     }
>     std::wfilebuf fb;
>     fb.pubimbue (std::locale ("en_US.UTF-8"));
>     fb.open ("file", std::ios::in);
>     const int c[] = { fb.sbumpc (), fb.sgetc () };
>     std::cout << c [0] << ' ' << c [1] << std::endl;
>     assert (L'a' == c [0]);
>     assert (std::wfilebuf::traits_type::eof () == c [1]);
> }
> test: test.cpp:21: int main(): Assertion `std::wfilebuf::traits_type::eof () == c [1]' failed.
> Aborted

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


Re: [jira] Commented: (STDCXX-333) std::wfilebuf extracts more than 1 character from a 1 byte file

Posted by Martin Sebor <se...@roguewave.com>.
Martin Sebor wrote:
> Mark Brown wrote:
>> I decided to look into this as an exercise in stdcxx debugging and
>> managed to figure out how to get around the error and generate the
>> en_US.UTF-8 locale.
> 
> Great! Thanks for the detective work!
> 
>> The change I made to make it work is in the
>> attached patch file. Let me know if this is the correct format
>> for patches or if you prefer something else.

I should have mentioned: when posting patches to the list please
start the subject line with the string "[PATCH]" to make it stand
out. It's also good to give the email a descriptive title, or
change it to one when following up on an unrelated topic (as in
this case :)

Read the section below for more on how to submit patches:
http://incubator.apache.org/stdcxx/bugs.html#patches

Martin

> 
> I don't see the patch. Did you forget to attach it? (Sometimes the
> attachments end up getting stripped by ezmlm even though they
> shouldn't). If it's small, you might want to paste it directly into
> your mail. Otherwise you might need to post it somewhere (e.g., on
> your web page or in the issue itself).
> 
>>
>> Incidentally, the original test program for stdcxx-333 runs fine
>> on Cygwin with the en_US.UTF-8 locale so the error must be unique
>> to Linux.
> 
> Hmm. Very odd.
> 
> Martin
> 
>>
>> -- Mark
>>
>>
>>> -----Original Message-----
>>> From: mbrown@inbox.com
>>> Sent: Mon, 19 Feb 2007 12:51:24 -0800
>>> To: stdcxx-dev@incubator.apache.org, stdcxx-dev@incubator.apache.org
>>> Subject: Re: [jira] Commented: (STDCXX-333) std::wfilebuf extracts more
>>> than 1 character from a 1 byte file
>>>
>>>> -----Original Message-----
>>>> From: sebor@roguewave.com
>>>> Sent: Mon, 19 Feb 2007 13:35:19 -0700
>>>> To: stdcxx-dev@incubator.apache.org
>>>> Subject: Re: [jira] Commented: (STDCXX-333) std::wfilebuf extracts more
>>>> than 1 character from a 1 byte file
>>>>
>>>> Mark Brown (JIRA) wrote:
>>>>>     [
>>> https://issues.apache.org/jira/browse/STDCXX-333?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12474266 
>>>
>>>>> ]
>>>>>
>>>>> Mark Brown commented on STDCXX-333:
>>>>> -----------------------------------
>>>>>
>>>>> I tried to see if I could reproduce this problem on Cygwin. My version
>>>>> of Cygwin doesn't have any locales so I tried to generate the
>>>>> en_US.UTF-8 locale using the stdcxx localedef program. I got this
>>>>> error:
>>>>>
>>>>> nls$ ../bin/localedef -c -f /home/mbrown/stdcxx/etc/nls/charmaps/UTF-8
>>>>> -i /home/mbrown/stdcxx/etc/nls/src/en_US en_US.UTF-8
>>>>> call to system LC_ALL=C /usr/bin/locale -a >/tmp/tdf4.0 
>>>>> 2>/dev/null: No
>>>>> such file or directory
>>>>> Hangup
>>>> This looks like an unrelated problem. Could you open a new issue for 
>>>> it?
>>> Sure. Here it is: https://issues.apache.org/jira/browse/STDCXX-340.
>>>
>>> Mark
>>>
>>>> Thanks
>>>> Martin
>>>>
>>>>>
>>>>>> std::wfilebuf extracts more than 1 character from a 1 byte file
>>>>>> ---------------------------------------------------------------
>>>>>>
>>>>>>                 Key: STDCXX-333
>>>>>>                 URL: https://issues.apache.org/jira/browse/STDCXX-333
>>>>>>             Project: C++ Standard Library
>>>>>>          Issue Type: Bug
>>>>>>          Components: 27. Input/Output
>>>>>>    Affects Versions: 4.1.3
>>>>>>         Environment: gcc 3.2.3 on Linux
>>>>>>            Reporter: Mark Brown
>>>>>>
>>>>>> I get an an abort when I run the following program on Linux.
>>>>>> #include <cassert>
>>>>>> #include <fstream>
>>>>>> #include <iostream>
>>>>>> int main ()
>>>>>> {
>>>>>>     {
>>>>>>         std::filebuf fb;
>>>>>>         fb.open ("file", std::ios::out);
>>>>>>         fb.sputc ('a');
>>>>>>     }
>>>>>>     std::wfilebuf fb;
>>>>>>     fb.pubimbue (std::locale ("en_US.UTF-8"));
>>>>>>     fb.open ("file", std::ios::in);
>>>>>>     const int c[] = { fb.sbumpc (), fb.sgetc () };
>>>>>>     std::cout << c [0] << ' ' << c [1] << std::endl;
>>>>>>     assert (L'a' == c [0]);
>>>>>>     assert (std::wfilebuf::traits_type::eof () == c [1]);
>>>>>> }
>>>>>> test: test.cpp:21: int main(): Assertion
>>>>>> `std::wfilebuf::traits_type::eof () == c [1]' failed.
>>>>>> Aborted
> 
> 
> 
> 



[PATCH] for stdcxx-340 (was: Re: [jira] Commented: (STDCXX-333) std::wfilebuf extracts more than 1 character from a 1 byte file)

Posted by Martin Sebor <se...@roguewave.com>.
Mark Brown wrote:
> I did attach the file. Your list software must have stripped it.
> Here it is again:

Makes sense. It looks to me like someone has already tried to deal
with this (or similar) problem before (the if (ret && ret != 256)
conditional) but it obviously doesn't work on Cygwin.

I've committed your patch here:
   http://svn.apache.org/viewvc?view=rev&rev=509359

Thanks
Martin

> 
> Index: /home/mbrown/stdcxx/util/aliases.cpp
> ===================================================================
> --- /home/mbrown/stdcxx/util/aliases.cpp        (revision 506161)
> +++ /home/mbrown/stdcxx/util/aliases.cpp        (working copy)
> @@ -32,9 +32,12 @@
>  #  include <sys/types.h>
>  #endif   // __linux__
>  
> +#include "diagnostic.h"
> +
>  #include <rw/_defs.h>
>  
>  #include <cassert>   // for assert()
> +#include <cerrno>    // for errno
>  #include <cstdlib>
>  #include <cstdio>
>  #include <cstring>   // for memcpy(), strlen()
> @@ -588,11 +591,9 @@
>  
>      const int ret = std::system (cmd);
>  
> -    if (ret && ret != 256) {
> -        std::strcpy (slocname, "call to system ");
> -        std::perror (std::strcat (slocname, cmd));
> -        std::abort ();
> -    }
> +    if (ret)
> +      issue_diag (W_NOTSUP, false, 0, "call to system(\"%s\") failed: %s\n",
> +                 cmd, std::strerror (errno));
>  
>      // open file containing the list of installed locales
>      std::FILE *f = std::fopen (fname, "r");
> 
> -- Mark
> 
> 
>> -----Original Message-----
>> From: sebor@roguewave.com
>> Sent: Mon, 19 Feb 2007 14:34:30 -0700
>> To: stdcxx-dev@incubator.apache.org
>> Subject: Re: [jira] Commented: (STDCXX-333) std::wfilebuf extracts more
>> than 1 character from a 1 byte file
>>
>> Mark Brown wrote:
>>> I decided to look into this as an exercise in stdcxx debugging and
>>> managed to figure out how to get around the error and generate the
>>> en_US.UTF-8 locale.
>> Great! Thanks for the detective work!
>>
>>> The change I made to make it work is in the
>>> attached patch file. Let me know if this is the correct format
>>> for patches or if you prefer something else.
>> I don't see the patch. Did you forget to attach it? (Sometimes the
>> attachments end up getting stripped by ezmlm even though they
>> shouldn't). If it's small, you might want to paste it directly into
>> your mail. Otherwise you might need to post it somewhere (e.g., on
>> your web page or in the issue itself).
>>
>>> Incidentally, the original test program for stdcxx-333 runs fine
>>> on Cygwin with the en_US.UTF-8 locale so the error must be unique
>>> to Linux.
>> Hmm. Very odd.
>>
>> Martin
>>
>>> -- Mark
>>>
>>>
>>>> -----Original Message-----
>>>> From: mbrown@inbox.com
>>>> Sent: Mon, 19 Feb 2007 12:51:24 -0800
>>>> To: stdcxx-dev@incubator.apache.org, stdcxx-dev@incubator.apache.org
>>>> Subject: Re: [jira] Commented: (STDCXX-333) std::wfilebuf extracts more
>>>> than 1 character from a 1 byte file
>>>>
>>>>> -----Original Message-----
>>>>> From: sebor@roguewave.com
>>>>> Sent: Mon, 19 Feb 2007 13:35:19 -0700
>>>>> To: stdcxx-dev@incubator.apache.org
>>>>> Subject: Re: [jira] Commented: (STDCXX-333) std::wfilebuf extracts
>>>>> more
>>>>> than 1 character from a 1 byte file
>>>>>
>>>>> Mark Brown (JIRA) wrote:
>>>>>>     [
>>>> https://issues.apache.org/jira/browse/STDCXX-333?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12474266
>>>>>> ]
>>>>>>
>>>>>> Mark Brown commented on STDCXX-333:
>>>>>> -----------------------------------
>>>>>>
>>>>>> I tried to see if I could reproduce this problem on Cygwin. My
>>>>>> version
>>>>>> of Cygwin doesn't have any locales so I tried to generate the
>>>>>> en_US.UTF-8 locale using the stdcxx localedef program. I got this
>>>>>> error:
>>>>>>
>>>>>> nls$ ../bin/localedef -c -f
>>>>>> /home/mbrown/stdcxx/etc/nls/charmaps/UTF-8
>>>>>> -i /home/mbrown/stdcxx/etc/nls/src/en_US en_US.UTF-8
>>>>>> call to system LC_ALL=C /usr/bin/locale -a >/tmp/tdf4.0 2>/dev/null:
>>>>>> No
>>>>>> such file or directory
>>>>>> Hangup
>>>>> This looks like an unrelated problem. Could you open a new issue for
>>>>> it?
>>>> Sure. Here it is: https://issues.apache.org/jira/browse/STDCXX-340.
>>>>
>>>> Mark
>>>>
>>>>> Thanks
>>>>> Martin
>>>>>
>>>>>>> std::wfilebuf extracts more than 1 character from a 1 byte file
>>>>>>> ---------------------------------------------------------------
>>>>>>>
>>>>>>>                 Key: STDCXX-333
>>>>>>>                 URL:
>>>>>>> https://issues.apache.org/jira/browse/STDCXX-333
>>>>>>>             Project: C++ Standard Library
>>>>>>>          Issue Type: Bug
>>>>>>>          Components: 27. Input/Output
>>>>>>>    Affects Versions: 4.1.3
>>>>>>>         Environment: gcc 3.2.3 on Linux
>>>>>>>            Reporter: Mark Brown
>>>>>>>
>>>>>>> I get an an abort when I run the following program on Linux.
>>>>>>> #include <cassert>
>>>>>>> #include <fstream>
>>>>>>> #include <iostream>
>>>>>>> int main ()
>>>>>>> {
>>>>>>>     {
>>>>>>>         std::filebuf fb;
>>>>>>>         fb.open ("file", std::ios::out);
>>>>>>>         fb.sputc ('a');
>>>>>>>     }
>>>>>>>     std::wfilebuf fb;
>>>>>>>     fb.pubimbue (std::locale ("en_US.UTF-8"));
>>>>>>>     fb.open ("file", std::ios::in);
>>>>>>>     const int c[] = { fb.sbumpc (), fb.sgetc () };
>>>>>>>     std::cout << c [0] << ' ' << c [1] << std::endl;
>>>>>>>     assert (L'a' == c [0]);
>>>>>>>     assert (std::wfilebuf::traits_type::eof () == c [1]);
>>>>>>> }
>>>>>>> test: test.cpp:21: int main(): Assertion
>>>>>>> `std::wfilebuf::traits_type::eof () == c [1]' failed.
>>>>>>> Aborted



Re: [jira] Commented: (STDCXX-333) std::wfilebuf extracts more than 1 character from a 1 byte file

Posted by Mark Brown <mb...@inbox.com>.
I did attach the file. Your list software must have stripped it.
Here it is again:

Index: /home/mbrown/stdcxx/util/aliases.cpp
===================================================================
--- /home/mbrown/stdcxx/util/aliases.cpp        (revision 506161)
+++ /home/mbrown/stdcxx/util/aliases.cpp        (working copy)
@@ -32,9 +32,12 @@
 #  include <sys/types.h>
 #endif   // __linux__
 
+#include "diagnostic.h"
+
 #include <rw/_defs.h>
 
 #include <cassert>   // for assert()
+#include <cerrno>    // for errno
 #include <cstdlib>
 #include <cstdio>
 #include <cstring>   // for memcpy(), strlen()
@@ -588,11 +591,9 @@
 
     const int ret = std::system (cmd);
 
-    if (ret && ret != 256) {
-        std::strcpy (slocname, "call to system ");
-        std::perror (std::strcat (slocname, cmd));
-        std::abort ();
-    }
+    if (ret)
+      issue_diag (W_NOTSUP, false, 0, "call to system(\"%s\") failed: %s\n",
+                 cmd, std::strerror (errno));
 
     // open file containing the list of installed locales
     std::FILE *f = std::fopen (fname, "r");

-- Mark


> -----Original Message-----
> From: sebor@roguewave.com
> Sent: Mon, 19 Feb 2007 14:34:30 -0700
> To: stdcxx-dev@incubator.apache.org
> Subject: Re: [jira] Commented: (STDCXX-333) std::wfilebuf extracts more
> than 1 character from a 1 byte file
> 
> Mark Brown wrote:
>> I decided to look into this as an exercise in stdcxx debugging and
>> managed to figure out how to get around the error and generate the
>> en_US.UTF-8 locale.
> 
> Great! Thanks for the detective work!
> 
>> The change I made to make it work is in the
>> attached patch file. Let me know if this is the correct format
>> for patches or if you prefer something else.
> 
> I don't see the patch. Did you forget to attach it? (Sometimes the
> attachments end up getting stripped by ezmlm even though they
> shouldn't). If it's small, you might want to paste it directly into
> your mail. Otherwise you might need to post it somewhere (e.g., on
> your web page or in the issue itself).
> 
>> 
>> Incidentally, the original test program for stdcxx-333 runs fine
>> on Cygwin with the en_US.UTF-8 locale so the error must be unique
>> to Linux.
> 
> Hmm. Very odd.
> 
> Martin
> 
>> 
>> -- Mark
>> 
>> 
>>> -----Original Message-----
>>> From: mbrown@inbox.com
>>> Sent: Mon, 19 Feb 2007 12:51:24 -0800
>>> To: stdcxx-dev@incubator.apache.org, stdcxx-dev@incubator.apache.org
>>> Subject: Re: [jira] Commented: (STDCXX-333) std::wfilebuf extracts more
>>> than 1 character from a 1 byte file
>>> 
>>>> -----Original Message-----
>>>> From: sebor@roguewave.com
>>>> Sent: Mon, 19 Feb 2007 13:35:19 -0700
>>>> To: stdcxx-dev@incubator.apache.org
>>>> Subject: Re: [jira] Commented: (STDCXX-333) std::wfilebuf extracts
>>>> more
>>>> than 1 character from a 1 byte file
>>>> 
>>>> Mark Brown (JIRA) wrote:
>>>>>     [
>>> https://issues.apache.org/jira/browse/STDCXX-333?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12474266
>>>>> ]
>>>>> 
>>>>> Mark Brown commented on STDCXX-333:
>>>>> -----------------------------------
>>>>> 
>>>>> I tried to see if I could reproduce this problem on Cygwin. My
>>>>> version
>>>>> of Cygwin doesn't have any locales so I tried to generate the
>>>>> en_US.UTF-8 locale using the stdcxx localedef program. I got this
>>>>> error:
>>>>> 
>>>>> nls$ ../bin/localedef -c -f
>>>>> /home/mbrown/stdcxx/etc/nls/charmaps/UTF-8
>>>>> -i /home/mbrown/stdcxx/etc/nls/src/en_US en_US.UTF-8
>>>>> call to system LC_ALL=C /usr/bin/locale -a >/tmp/tdf4.0 2>/dev/null:
>>>>> No
>>>>> such file or directory
>>>>> Hangup
>>>> This looks like an unrelated problem. Could you open a new issue for
>>>> it?
>>> Sure. Here it is: https://issues.apache.org/jira/browse/STDCXX-340.
>>> 
>>> Mark
>>> 
>>>> Thanks
>>>> Martin
>>>> 
>>>>> 
>>>>>> std::wfilebuf extracts more than 1 character from a 1 byte file
>>>>>> ---------------------------------------------------------------
>>>>>> 
>>>>>>                 Key: STDCXX-333
>>>>>>                 URL:
>>>>>> https://issues.apache.org/jira/browse/STDCXX-333
>>>>>>             Project: C++ Standard Library
>>>>>>          Issue Type: Bug
>>>>>>          Components: 27. Input/Output
>>>>>>    Affects Versions: 4.1.3
>>>>>>         Environment: gcc 3.2.3 on Linux
>>>>>>            Reporter: Mark Brown
>>>>>> 
>>>>>> I get an an abort when I run the following program on Linux.
>>>>>> #include <cassert>
>>>>>> #include <fstream>
>>>>>> #include <iostream>
>>>>>> int main ()
>>>>>> {
>>>>>>     {
>>>>>>         std::filebuf fb;
>>>>>>         fb.open ("file", std::ios::out);
>>>>>>         fb.sputc ('a');
>>>>>>     }
>>>>>>     std::wfilebuf fb;
>>>>>>     fb.pubimbue (std::locale ("en_US.UTF-8"));
>>>>>>     fb.open ("file", std::ios::in);
>>>>>>     const int c[] = { fb.sbumpc (), fb.sgetc () };
>>>>>>     std::cout << c [0] << ' ' << c [1] << std::endl;
>>>>>>     assert (L'a' == c [0]);
>>>>>>     assert (std::wfilebuf::traits_type::eof () == c [1]);
>>>>>> }
>>>>>> test: test.cpp:21: int main(): Assertion
>>>>>> `std::wfilebuf::traits_type::eof () == c [1]' failed.
>>>>>> Aborted

Re: [jira] Commented: (STDCXX-333) std::wfilebuf extracts more than 1 character from a 1 byte file

Posted by Martin Sebor <se...@roguewave.com>.
Mark Brown wrote:
> I decided to look into this as an exercise in stdcxx debugging and
> managed to figure out how to get around the error and generate the
> en_US.UTF-8 locale.

Great! Thanks for the detective work!

> The change I made to make it work is in the
> attached patch file. Let me know if this is the correct format
> for patches or if you prefer something else.

I don't see the patch. Did you forget to attach it? (Sometimes the
attachments end up getting stripped by ezmlm even though they
shouldn't). If it's small, you might want to paste it directly into
your mail. Otherwise you might need to post it somewhere (e.g., on
your web page or in the issue itself).

> 
> Incidentally, the original test program for stdcxx-333 runs fine
> on Cygwin with the en_US.UTF-8 locale so the error must be unique
> to Linux.

Hmm. Very odd.

Martin

> 
> -- Mark
> 
> 
>> -----Original Message-----
>> From: mbrown@inbox.com
>> Sent: Mon, 19 Feb 2007 12:51:24 -0800
>> To: stdcxx-dev@incubator.apache.org, stdcxx-dev@incubator.apache.org
>> Subject: Re: [jira] Commented: (STDCXX-333) std::wfilebuf extracts more
>> than 1 character from a 1 byte file
>>
>>> -----Original Message-----
>>> From: sebor@roguewave.com
>>> Sent: Mon, 19 Feb 2007 13:35:19 -0700
>>> To: stdcxx-dev@incubator.apache.org
>>> Subject: Re: [jira] Commented: (STDCXX-333) std::wfilebuf extracts more
>>> than 1 character from a 1 byte file
>>>
>>> Mark Brown (JIRA) wrote:
>>>>     [
>> https://issues.apache.org/jira/browse/STDCXX-333?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12474266
>>>> ]
>>>>
>>>> Mark Brown commented on STDCXX-333:
>>>> -----------------------------------
>>>>
>>>> I tried to see if I could reproduce this problem on Cygwin. My version
>>>> of Cygwin doesn't have any locales so I tried to generate the
>>>> en_US.UTF-8 locale using the stdcxx localedef program. I got this
>>>> error:
>>>>
>>>> nls$ ../bin/localedef -c -f /home/mbrown/stdcxx/etc/nls/charmaps/UTF-8
>>>> -i /home/mbrown/stdcxx/etc/nls/src/en_US en_US.UTF-8
>>>> call to system LC_ALL=C /usr/bin/locale -a >/tmp/tdf4.0 2>/dev/null: No
>>>> such file or directory
>>>> Hangup
>>> This looks like an unrelated problem. Could you open a new issue for it?
>> Sure. Here it is: https://issues.apache.org/jira/browse/STDCXX-340.
>>
>> Mark
>>
>>> Thanks
>>> Martin
>>>
>>>>
>>>>> std::wfilebuf extracts more than 1 character from a 1 byte file
>>>>> ---------------------------------------------------------------
>>>>>
>>>>>                 Key: STDCXX-333
>>>>>                 URL: https://issues.apache.org/jira/browse/STDCXX-333
>>>>>             Project: C++ Standard Library
>>>>>          Issue Type: Bug
>>>>>          Components: 27. Input/Output
>>>>>    Affects Versions: 4.1.3
>>>>>         Environment: gcc 3.2.3 on Linux
>>>>>            Reporter: Mark Brown
>>>>>
>>>>> I get an an abort when I run the following program on Linux.
>>>>> #include <cassert>
>>>>> #include <fstream>
>>>>> #include <iostream>
>>>>> int main ()
>>>>> {
>>>>>     {
>>>>>         std::filebuf fb;
>>>>>         fb.open ("file", std::ios::out);
>>>>>         fb.sputc ('a');
>>>>>     }
>>>>>     std::wfilebuf fb;
>>>>>     fb.pubimbue (std::locale ("en_US.UTF-8"));
>>>>>     fb.open ("file", std::ios::in);
>>>>>     const int c[] = { fb.sbumpc (), fb.sgetc () };
>>>>>     std::cout << c [0] << ' ' << c [1] << std::endl;
>>>>>     assert (L'a' == c [0]);
>>>>>     assert (std::wfilebuf::traits_type::eof () == c [1]);
>>>>> }
>>>>> test: test.cpp:21: int main(): Assertion
>>>>> `std::wfilebuf::traits_type::eof () == c [1]' failed.
>>>>> Aborted



Re: [jira] Commented: (STDCXX-333) std::wfilebuf extracts more than 1 character from a 1 byte file

Posted by Mark Brown <mb...@inbox.com>.
I decided to look into this as an exercise in stdcxx debugging and
managed to figure out how to get around the error and generate the
en_US.UTF-8 locale. The change I made to make it work is in the
attached patch file. Let me know if this is the correct format
for patches or if you prefer something else.

Incidentally, the original test program for stdcxx-333 runs fine
on Cygwin with the en_US.UTF-8 locale so the error must be unique
to Linux.

-- Mark


> -----Original Message-----
> From: mbrown@inbox.com
> Sent: Mon, 19 Feb 2007 12:51:24 -0800
> To: stdcxx-dev@incubator.apache.org, stdcxx-dev@incubator.apache.org
> Subject: Re: [jira] Commented: (STDCXX-333) std::wfilebuf extracts more
> than 1 character from a 1 byte file
> 
>> -----Original Message-----
>> From: sebor@roguewave.com
>> Sent: Mon, 19 Feb 2007 13:35:19 -0700
>> To: stdcxx-dev@incubator.apache.org
>> Subject: Re: [jira] Commented: (STDCXX-333) std::wfilebuf extracts more
>> than 1 character from a 1 byte file
>> 
>> Mark Brown (JIRA) wrote:
>>>     [
> https://issues.apache.org/jira/browse/STDCXX-333?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12474266
>>> ]
>>> 
>>> Mark Brown commented on STDCXX-333:
>>> -----------------------------------
>>> 
>>> I tried to see if I could reproduce this problem on Cygwin. My version
>>> of Cygwin doesn't have any locales so I tried to generate the
>>> en_US.UTF-8 locale using the stdcxx localedef program. I got this
>>> error:
>>> 
>>> nls$ ../bin/localedef -c -f /home/mbrown/stdcxx/etc/nls/charmaps/UTF-8
>>> -i /home/mbrown/stdcxx/etc/nls/src/en_US en_US.UTF-8
>>> call to system LC_ALL=C /usr/bin/locale -a >/tmp/tdf4.0 2>/dev/null: No
>>> such file or directory
>>> Hangup
>> 
>> This looks like an unrelated problem. Could you open a new issue for it?
> 
> Sure. Here it is: https://issues.apache.org/jira/browse/STDCXX-340.
> 
> Mark
> 
>> 
>> Thanks
>> Martin
>> 
>>> 
>>> 
>>>> std::wfilebuf extracts more than 1 character from a 1 byte file
>>>> ---------------------------------------------------------------
>>>> 
>>>>                 Key: STDCXX-333
>>>>                 URL: https://issues.apache.org/jira/browse/STDCXX-333
>>>>             Project: C++ Standard Library
>>>>          Issue Type: Bug
>>>>          Components: 27. Input/Output
>>>>    Affects Versions: 4.1.3
>>>>         Environment: gcc 3.2.3 on Linux
>>>>            Reporter: Mark Brown
>>>> 
>>>> I get an an abort when I run the following program on Linux.
>>>> #include <cassert>
>>>> #include <fstream>
>>>> #include <iostream>
>>>> int main ()
>>>> {
>>>>     {
>>>>         std::filebuf fb;
>>>>         fb.open ("file", std::ios::out);
>>>>         fb.sputc ('a');
>>>>     }
>>>>     std::wfilebuf fb;
>>>>     fb.pubimbue (std::locale ("en_US.UTF-8"));
>>>>     fb.open ("file", std::ios::in);
>>>>     const int c[] = { fb.sbumpc (), fb.sgetc () };
>>>>     std::cout << c [0] << ' ' << c [1] << std::endl;
>>>>     assert (L'a' == c [0]);
>>>>     assert (std::wfilebuf::traits_type::eof () == c [1]);
>>>> }
>>>> test: test.cpp:21: int main(): Assertion
>>>> `std::wfilebuf::traits_type::eof () == c [1]' failed.
>>>> Aborted
>>> 

Re: [jira] Commented: (STDCXX-333) std::wfilebuf extracts more than 1 character from a 1 byte file

Posted by Mark Brown <mb...@inbox.com>.
> -----Original Message-----
> From: sebor@roguewave.com
> Sent: Mon, 19 Feb 2007 13:35:19 -0700
> To: stdcxx-dev@incubator.apache.org
> Subject: Re: [jira] Commented: (STDCXX-333) std::wfilebuf extracts more
> than 1 character from a 1 byte file
> 
> Mark Brown (JIRA) wrote:
>>     [
https://issues.apache.org/jira/browse/STDCXX-333?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12474266
>> ]
>> 
>> Mark Brown commented on STDCXX-333:
>> -----------------------------------
>> 
>> I tried to see if I could reproduce this problem on Cygwin. My version
>> of Cygwin doesn't have any locales so I tried to generate the
>> en_US.UTF-8 locale using the stdcxx localedef program. I got this error:
>> 
>> nls$ ../bin/localedef -c -f /home/mbrown/stdcxx/etc/nls/charmaps/UTF-8
>> -i /home/mbrown/stdcxx/etc/nls/src/en_US en_US.UTF-8
>> call to system LC_ALL=C /usr/bin/locale -a >/tmp/tdf4.0 2>/dev/null: No
>> such file or directory
>> Hangup
> 
> This looks like an unrelated problem. Could you open a new issue for it?

Sure. Here it is: https://issues.apache.org/jira/browse/STDCXX-340.

Mark

> 
> Thanks
> Martin
> 
>> 
>> 
>>> std::wfilebuf extracts more than 1 character from a 1 byte file
>>> ---------------------------------------------------------------
>>> 
>>>                 Key: STDCXX-333
>>>                 URL: https://issues.apache.org/jira/browse/STDCXX-333
>>>             Project: C++ Standard Library
>>>          Issue Type: Bug
>>>          Components: 27. Input/Output
>>>    Affects Versions: 4.1.3
>>>         Environment: gcc 3.2.3 on Linux
>>>            Reporter: Mark Brown
>>> 
>>> I get an an abort when I run the following program on Linux.
>>> #include <cassert>
>>> #include <fstream>
>>> #include <iostream>
>>> int main ()
>>> {
>>>     {
>>>         std::filebuf fb;
>>>         fb.open ("file", std::ios::out);
>>>         fb.sputc ('a');
>>>     }
>>>     std::wfilebuf fb;
>>>     fb.pubimbue (std::locale ("en_US.UTF-8"));
>>>     fb.open ("file", std::ios::in);
>>>     const int c[] = { fb.sbumpc (), fb.sgetc () };
>>>     std::cout << c [0] << ' ' << c [1] << std::endl;
>>>     assert (L'a' == c [0]);
>>>     assert (std::wfilebuf::traits_type::eof () == c [1]);
>>> }
>>> test: test.cpp:21: int main(): Assertion
>>> `std::wfilebuf::traits_type::eof () == c [1]' failed.
>>> Aborted
>> 

Re: [jira] Commented: (STDCXX-333) std::wfilebuf extracts more than 1 character from a 1 byte file

Posted by Martin Sebor <se...@roguewave.com>.
Mark Brown (JIRA) wrote:
>     [ https://issues.apache.org/jira/browse/STDCXX-333?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12474266 ] 
> 
> Mark Brown commented on STDCXX-333:
> -----------------------------------
> 
> I tried to see if I could reproduce this problem on Cygwin. My version of Cygwin doesn't have any locales so I tried to generate the en_US.UTF-8 locale using the stdcxx localedef program. I got this error:
> 
> nls$ ../bin/localedef -c -f /home/mbrown/stdcxx/etc/nls/charmaps/UTF-8 -i /home/mbrown/stdcxx/etc/nls/src/en_US en_US.UTF-8
> call to system LC_ALL=C /usr/bin/locale -a >/tmp/tdf4.0 2>/dev/null: No such file or directory
> Hangup

This looks like an unrelated problem. Could you open a new issue for it?

Thanks
Martin

> 
> 
>> std::wfilebuf extracts more than 1 character from a 1 byte file
>> ---------------------------------------------------------------
>>
>>                 Key: STDCXX-333
>>                 URL: https://issues.apache.org/jira/browse/STDCXX-333
>>             Project: C++ Standard Library
>>          Issue Type: Bug
>>          Components: 27. Input/Output
>>    Affects Versions: 4.1.3
>>         Environment: gcc 3.2.3 on Linux
>>            Reporter: Mark Brown
>>
>> I get an an abort when I run the following program on Linux.
>> #include <cassert>
>> #include <fstream>
>> #include <iostream>
>> int main ()
>> {
>>     {
>>         std::filebuf fb;
>>         fb.open ("file", std::ios::out);
>>         fb.sputc ('a');
>>     }
>>     std::wfilebuf fb;
>>     fb.pubimbue (std::locale ("en_US.UTF-8"));
>>     fb.open ("file", std::ios::in);
>>     const int c[] = { fb.sbumpc (), fb.sgetc () };
>>     std::cout << c [0] << ' ' << c [1] << std::endl;
>>     assert (L'a' == c [0]);
>>     assert (std::wfilebuf::traits_type::eof () == c [1]);
>> }
>> test: test.cpp:21: int main(): Assertion `std::wfilebuf::traits_type::eof () == c [1]' failed.
>> Aborted
> 



[jira] Commented: (STDCXX-333) std::wfilebuf extracts more than 1 character from a 1 byte file

Posted by "Mark Brown (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/STDCXX-333?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12474266 ] 

Mark Brown commented on STDCXX-333:
-----------------------------------

I tried to see if I could reproduce this problem on Cygwin. My version of Cygwin doesn't have any locales so I tried to generate the en_US.UTF-8 locale using the stdcxx localedef program. I got this error:

nls$ ../bin/localedef -c -f /home/mbrown/stdcxx/etc/nls/charmaps/UTF-8 -i /home/mbrown/stdcxx/etc/nls/src/en_US en_US.UTF-8
call to system LC_ALL=C /usr/bin/locale -a >/tmp/tdf4.0 2>/dev/null: No such file or directory
Hangup


> std::wfilebuf extracts more than 1 character from a 1 byte file
> ---------------------------------------------------------------
>
>                 Key: STDCXX-333
>                 URL: https://issues.apache.org/jira/browse/STDCXX-333
>             Project: C++ Standard Library
>          Issue Type: Bug
>          Components: 27. Input/Output
>    Affects Versions: 4.1.3
>         Environment: gcc 3.2.3 on Linux
>            Reporter: Mark Brown
>
> I get an an abort when I run the following program on Linux.
> #include <cassert>
> #include <fstream>
> #include <iostream>
> int main ()
> {
>     {
>         std::filebuf fb;
>         fb.open ("file", std::ios::out);
>         fb.sputc ('a');
>     }
>     std::wfilebuf fb;
>     fb.pubimbue (std::locale ("en_US.UTF-8"));
>     fb.open ("file", std::ios::in);
>     const int c[] = { fb.sbumpc (), fb.sgetc () };
>     std::cout << c [0] << ' ' << c [1] << std::endl;
>     assert (L'a' == c [0]);
>     assert (std::wfilebuf::traits_type::eof () == c [1]);
> }
> test: test.cpp:21: int main(): Assertion `std::wfilebuf::traits_type::eof () == c [1]' failed.
> Aborted

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


[jira] Commented: (STDCXX-333) std::wfilebuf extracts more than 1 character from a 1 byte file

Posted by "Martin Sebor (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/STDCXX-333?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12469901 ] 

Martin Sebor commented on STDCXX-333:
-------------------------------------

How odd. I can reproduce this but only intermittently and with different results:

$ while [ $? -eq 0 ]; do ./t; done; true; while [ $? -eq 0 ]; do ./t; done
97 -1
97 -1
97 -1
97 -1
97 8
t: t.cpp:21: int main(): Assertion `std::wfilebuf::traits_type::eof () == c [1]' failed.
Aborted
97 -1
97 -1
97 -1
97 -1
97 -1
97 -1
97 104
: t.cpp:21: int main(): Assertion `std::wfilebuf::traits_type::eof () == c [1]' failed.
Aborted


> std::wfilebuf extracts more than 1 character from a 1 byte file
> ---------------------------------------------------------------
>
>                 Key: STDCXX-333
>                 URL: https://issues.apache.org/jira/browse/STDCXX-333
>             Project: C++ Standard Library
>          Issue Type: Bug
>          Components: 27. Input/Output
>    Affects Versions: 4.1.3
>         Environment: gcc 3.2.3 on Linux
>            Reporter: Mark Brown
>
> I get an an abort when I run the following program on Linux.
> #include <cassert>
> #include <fstream>
> #include <iostream>
> int main ()
> {
>     {
>         std::filebuf fb;
>         fb.open ("file", std::ios::out);
>         fb.sputc ('a');
>     }
>     std::wfilebuf fb;
>     fb.pubimbue (std::locale ("en_US.UTF-8"));
>     fb.open ("file", std::ios::in);
>     const int c[] = { fb.sbumpc (), fb.sgetc () };
>     std::cout << c [0] << ' ' << c [1] << std::endl;
>     assert (L'a' == c [0]);
>     assert (std::wfilebuf::traits_type::eof () == c [1]);
> }
> test: test.cpp:21: int main(): Assertion `std::wfilebuf::traits_type::eof () == c [1]' failed.
> Aborted

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


[jira] Assigned: (STDCXX-333) Linux] std::wfilebuf extracts more than 1 character from a 1 byte file

Posted by "Martin Sebor (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/STDCXX-333?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Martin Sebor reassigned STDCXX-333:
-----------------------------------

    Assignee: Martin Sebor

> Linux] std::wfilebuf extracts more than 1 character from a 1 byte file
> ----------------------------------------------------------------------
>
>                 Key: STDCXX-333
>                 URL: https://issues.apache.org/jira/browse/STDCXX-333
>             Project: C++ Standard Library
>          Issue Type: Bug
>          Components: 27. Input/Output
>    Affects Versions: 4.1.3
>         Environment: gcc 3.2.3 on Linux
>            Reporter: Mark Brown
>            Assignee: Martin Sebor
>            Priority: Minor
>
> I get an an abort when I run the following program on Linux.
> #include <cassert>
> #include <fstream>
> #include <iostream>
> int main ()
> {
>     {
>         std::filebuf fb;
>         fb.open ("file", std::ios::out);
>         fb.sputc ('a');
>     }
>     std::wfilebuf fb;
>     fb.pubimbue (std::locale ("en_US.UTF-8"));
>     fb.open ("file", std::ios::in);
>     const int c[] = { fb.sbumpc (), fb.sgetc () };
>     std::cout << c [0] << ' ' << c [1] << std::endl;
>     assert (L'a' == c [0]);
>     assert (std::wfilebuf::traits_type::eof () == c [1]);
> }
> test: test.cpp:21: int main(): Assertion `std::wfilebuf::traits_type::eof () == c [1]' failed.
> Aborted

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