public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/38741]  New: Unable to write data to wofstream
@ 2009-01-06  9:47 radhika dot ganganna at oracle dot com
  2009-01-06 20:23 ` [Bug libstdc++/38741] " pinskia at gcc dot gnu dot org
                   ` (14 more replies)
  0 siblings, 15 replies; 16+ messages in thread
From: radhika dot ganganna at oracle dot com @ 2009-01-06  9:47 UTC (permalink / raw)
  To: gcc-bugs

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1297 bytes --]

Hi,

I’m trying to create a csv file in Unicode format. I’m using wofstream to
create the file. 

I’m writing a series of strings and double values to the stream. 

I find that the values written to wofstream stop after writing 9 sets of data.
There are about 37 sets of data. 

What could be the issue? 

The code that writes data to wofstream is as below: 

for ( int i=0; i<str.length(); i++ )
 {
    wchar_t wc = ( str[i]<<16 );
    os << wc;
//     os.seekp( -1, ios_base::cur );
}


Where 

str:  wstring. 

os: wofstream 

gcc version 3.4.4 20050721 (Red Hat 3.4.4-2)



The above code is called 30-40 times for different values of str. 


If I uncomment os.seekp() statement,  the file is zero bytes.  

os.fail() is not showing any error. Unable to figure where things are failing. 

I’m able to output contents of str on standard ouput. But not able to write to
file completely. 


Regards,
Radhika


-- 
           Summary: Unable to write data to wofstream
           Product: gcc
           Version: 3.4.4
            Status: UNCONFIRMED
          Severity: critical
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: radhika dot ganganna at oracle dot com


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38741


^ permalink raw reply	[flat|nested] 16+ messages in thread

* [Bug libstdc++/38741] Unable to write data to wofstream
  2009-01-06  9:47 [Bug c++/38741] New: Unable to write data to wofstream radhika dot ganganna at oracle dot com
@ 2009-01-06 20:23 ` pinskia at gcc dot gnu dot org
  2009-01-07  6:35 ` radhika dot ganganna at oracle dot com
                   ` (13 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2009-01-06 20:23 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from pinskia at gcc dot gnu dot org  2009-01-06 20:23 -------
You did not supply a full testcase so it is hard to tell what is going on.  Can
you produce a short testcase which shows the problem.  It might be because the
wide character is an invalid character.  Since you are shifting the character
by 16, I would almost say this is always going to be an invalid character.

If str is already a wstring, then str[i] will already be a wchar_t and you
don't have to shift the value.  


-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|critical                    |normal
             Status|UNCONFIRMED                 |WAITING
          Component|c++                         |libstdc++
            Summary|Unable to write data to     |Unable to write data to
                   |wofstream                   |wofstream


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38741


^ permalink raw reply	[flat|nested] 16+ messages in thread

* [Bug libstdc++/38741] Unable to write data to wofstream
  2009-01-06  9:47 [Bug c++/38741] New: Unable to write data to wofstream radhika dot ganganna at oracle dot com
  2009-01-06 20:23 ` [Bug libstdc++/38741] " pinskia at gcc dot gnu dot org
@ 2009-01-07  6:35 ` radhika dot ganganna at oracle dot com
  2009-01-07 10:58 ` radhika dot ganganna at oracle dot com
                   ` (12 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: radhika dot ganganna at oracle dot com @ 2009-01-07  6:35 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from radhika dot ganganna at oracle dot com  2009-01-07 06:35 -------
Hi,
   Thanks for the reply. I would send the testcase soon. 
The issue seems to be that the output sent to wofstream stops updating the
stream after certain number of characters. In our case it's after 400+
characters. Has anybdy else faced this issue before? 
I tried using flush(). This writes some more data to stream. But still lot of
data is missing. How to sync the data in buffer with data written to file. 
Please let me know. 

Regards,
Radhika




(In reply to comment #1)
> You did not supply a full testcase so it is hard to tell what is going on.  Can
> you produce a short testcase which shows the problem.  It might be because the
> wide character is an invalid character.  Since you are shifting the character
> by 16, I would almost say this is always going to be an invalid character.
> If str is already a wstring, then str[i] will already be a wchar_t and you
> don't have to shift the value.  


-- 

radhika dot ganganna at oracle dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |radhika dot ganganna at
                   |                            |oracle dot com


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38741


^ permalink raw reply	[flat|nested] 16+ messages in thread

* [Bug libstdc++/38741] Unable to write data to wofstream
  2009-01-06  9:47 [Bug c++/38741] New: Unable to write data to wofstream radhika dot ganganna at oracle dot com
  2009-01-06 20:23 ` [Bug libstdc++/38741] " pinskia at gcc dot gnu dot org
  2009-01-07  6:35 ` radhika dot ganganna at oracle dot com
@ 2009-01-07 10:58 ` radhika dot ganganna at oracle dot com
  2009-01-08  8:58 ` radhika dot ganganna at oracle dot com
                   ` (11 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: radhika dot ganganna at oracle dot com @ 2009-01-07 10:58 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from radhika dot ganganna at oracle dot com  2009-01-07 10:58 -------
Created an attachment (id=17044)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=17044&action=view)
The testcase for the current issue

Please look into the code that's causing the issue. 
After outputting about 240 characters to file, the subsequent output is not
written to the file. 


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38741


^ permalink raw reply	[flat|nested] 16+ messages in thread

* [Bug libstdc++/38741] Unable to write data to wofstream
  2009-01-06  9:47 [Bug c++/38741] New: Unable to write data to wofstream radhika dot ganganna at oracle dot com
                   ` (2 preceding siblings ...)
  2009-01-07 10:58 ` radhika dot ganganna at oracle dot com
@ 2009-01-08  8:58 ` radhika dot ganganna at oracle dot com
  2009-01-08  8:59 ` radhika dot ganganna at oracle dot com
                   ` (10 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: radhika dot ganganna at oracle dot com @ 2009-01-08  8:58 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from radhika dot ganganna at oracle dot com  2009-01-08 08:58 -------
Created an attachment (id=17053)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=17053&action=view)
Testcase which demonstrates the error

The code writes the wstring "Forecast" 100 times to wofstream. 
When I executed the program it ouput the wstring 25 times and stopped. 
The wofstream doesn't set any error bit. 
Please let me know if there is some buffor which needs to be refreshed. How to
do it? 

Regards,
Radhika


-- 

radhika dot ganganna at oracle dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
  Attachment #17044|0                           |1
        is obsolete|                            |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38741


^ permalink raw reply	[flat|nested] 16+ messages in thread

* [Bug libstdc++/38741] Unable to write data to wofstream
  2009-01-06  9:47 [Bug c++/38741] New: Unable to write data to wofstream radhika dot ganganna at oracle dot com
                   ` (3 preceding siblings ...)
  2009-01-08  8:58 ` radhika dot ganganna at oracle dot com
@ 2009-01-08  8:59 ` radhika dot ganganna at oracle dot com
  2009-01-08 14:36 ` paolo dot carlini at oracle dot com
                   ` (9 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: radhika dot ganganna at oracle dot com @ 2009-01-08  8:59 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from radhika dot ganganna at oracle dot com  2009-01-08 08:59 -------
Created an attachment (id=17054)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=17054&action=view)
nullcodecvt.h needed to compile linuxunicode.cpp


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38741


^ permalink raw reply	[flat|nested] 16+ messages in thread

* [Bug libstdc++/38741] Unable to write data to wofstream
  2009-01-06  9:47 [Bug c++/38741] New: Unable to write data to wofstream radhika dot ganganna at oracle dot com
                   ` (4 preceding siblings ...)
  2009-01-08  8:59 ` radhika dot ganganna at oracle dot com
@ 2009-01-08 14:36 ` paolo dot carlini at oracle dot com
  2009-01-09  4:44 ` radhika dot ganganna at oracle dot com
                   ` (8 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: paolo dot carlini at oracle dot com @ 2009-01-08 14:36 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from paolo dot carlini at oracle dot com  2009-01-08 14:36 -------
I can't reproduce, neither with stock FSF gcc3.4.6 neither with current
gcc4.3.2 and mainline (I'm assuming you expect a 1002 bytes output). I suggest
testing a current FSF GCC release, and file a new PR in case you are still
having problems.


-- 

paolo dot carlini at oracle dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|WAITING                     |RESOLVED
         Resolution|                            |WORKSFORME


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38741


^ permalink raw reply	[flat|nested] 16+ messages in thread

* [Bug libstdc++/38741] Unable to write data to wofstream
  2009-01-06  9:47 [Bug c++/38741] New: Unable to write data to wofstream radhika dot ganganna at oracle dot com
                   ` (5 preceding siblings ...)
  2009-01-08 14:36 ` paolo dot carlini at oracle dot com
@ 2009-01-09  4:44 ` radhika dot ganganna at oracle dot com
  2009-01-09  9:41 ` paolo dot carlini at oracle dot com
                   ` (7 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: radhika dot ganganna at oracle dot com @ 2009-01-09  4:44 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #7 from radhika dot ganganna at oracle dot com  2009-01-09 04:44 -------
Hi Paolo,

The expected result is the string "Forecast" should be output 100 times to
wofstream. But it's ouput only 25 times. 

Regards,
Radhika


-- 

radhika dot ganganna at oracle dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |UNCONFIRMED
         Resolution|WORKSFORME                  |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38741


^ permalink raw reply	[flat|nested] 16+ messages in thread

* [Bug libstdc++/38741] Unable to write data to wofstream
  2009-01-06  9:47 [Bug c++/38741] New: Unable to write data to wofstream radhika dot ganganna at oracle dot com
                   ` (6 preceding siblings ...)
  2009-01-09  4:44 ` radhika dot ganganna at oracle dot com
@ 2009-01-09  9:41 ` paolo dot carlini at oracle dot com
  2009-01-09  9:56 ` paolo dot carlini at oracle dot com
                   ` (6 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: paolo dot carlini at oracle dot com @ 2009-01-09  9:41 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #8 from paolo dot carlini at oracle dot com  2009-01-09 09:41 -------
As I said, I'm seeing the expected final size, that is 1002. Also, I don't
think your testcase is correct, you don't want do_always_no_conv to return
true, nothing takes care in your codecvt of packing of properly converting each
in-memory wchar_t (4 bytes each) to the external chars you want.


-- 

paolo dot carlini at oracle dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |INVALID


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38741


^ permalink raw reply	[flat|nested] 16+ messages in thread

* [Bug libstdc++/38741] Unable to write data to wofstream
  2009-01-06  9:47 [Bug c++/38741] New: Unable to write data to wofstream radhika dot ganganna at oracle dot com
                   ` (7 preceding siblings ...)
  2009-01-09  9:41 ` paolo dot carlini at oracle dot com
@ 2009-01-09  9:56 ` paolo dot carlini at oracle dot com
  2009-01-09 10:09 ` radhika dot ganganna at oracle dot com
                   ` (5 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: paolo dot carlini at oracle dot com @ 2009-01-09  9:56 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #9 from paolo dot carlini at oracle dot com  2009-01-09 09:56 -------
... and, by the way, exactly because your codecvt is broken - doesn't properly
convert each in-memory wchar_t to a single external char - you maintain to see
1 / 4 of the expected "Forecast" strings: actually you are seeing the expected
total number of chars but each time, each char in "Forecast" is followed by 3
'\0' chars, the in-memory last three bytes of each wchar_t of L"Forecast".


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38741


^ permalink raw reply	[flat|nested] 16+ messages in thread

* [Bug libstdc++/38741] Unable to write data to wofstream
  2009-01-06  9:47 [Bug c++/38741] New: Unable to write data to wofstream radhika dot ganganna at oracle dot com
                   ` (8 preceding siblings ...)
  2009-01-09  9:56 ` paolo dot carlini at oracle dot com
@ 2009-01-09 10:09 ` radhika dot ganganna at oracle dot com
  2009-01-09 10:15 ` paolo dot carlini at oracle dot com
                   ` (4 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: radhika dot ganganna at oracle dot com @ 2009-01-09 10:09 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #10 from radhika dot ganganna at oracle dot com  2009-01-09 10:09 -------
Hi,

I'm afraid if it's an issue with codecvt as such. The same code generates the
expected ouput on all other unix platforms except Linux. 
The expected output is not 1002 bytes as suggested. Even if I output the string
just 10 times, it outputs only once correctly and only few character from the
second string is output. 

Regards,
Radhika


-- 

radhika dot ganganna at oracle dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |UNCONFIRMED
         Resolution|INVALID                     |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38741


^ permalink raw reply	[flat|nested] 16+ messages in thread

* [Bug libstdc++/38741] Unable to write data to wofstream
  2009-01-06  9:47 [Bug c++/38741] New: Unable to write data to wofstream radhika dot ganganna at oracle dot com
                   ` (9 preceding siblings ...)
  2009-01-09 10:09 ` radhika dot ganganna at oracle dot com
@ 2009-01-09 10:15 ` paolo dot carlini at oracle dot com
  2009-01-09 16:58 ` sebor at roguewave dot com
                   ` (3 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: paolo dot carlini at oracle dot com @ 2009-01-09 10:15 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #11 from paolo dot carlini at oracle dot com  2009-01-09 10:15 -------
Sorry, but I don't think your codecvt can wrok in any meaningful way as-is.
Either you provide more information as to why - basing on the exact citations
from the Standard - it should work, or we are not going to do anything.


-- 

paolo dot carlini at oracle dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |INVALID


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38741


^ permalink raw reply	[flat|nested] 16+ messages in thread

* [Bug libstdc++/38741] Unable to write data to wofstream
  2009-01-06  9:47 [Bug c++/38741] New: Unable to write data to wofstream radhika dot ganganna at oracle dot com
                   ` (10 preceding siblings ...)
  2009-01-09 10:15 ` paolo dot carlini at oracle dot com
@ 2009-01-09 16:58 ` sebor at roguewave dot com
  2009-01-12 10:48 ` radhika dot ganganna at oracle dot com
                   ` (2 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: sebor at roguewave dot com @ 2009-01-09 16:58 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #12 from sebor at roguewave dot com  2009-01-09 16:57 -------
(In reply to comment #3)
> Created an attachment (id=17044)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=17044&action=view) [edit]

As others have mentioned, the codecvt facet in your test case is broken.
The standard allows the codecvt::do_in() and do_out() members to return
noconv only when both intern_type and extern_type are the same type.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38741


^ permalink raw reply	[flat|nested] 16+ messages in thread

* [Bug libstdc++/38741] Unable to write data to wofstream
  2009-01-06  9:47 [Bug c++/38741] New: Unable to write data to wofstream radhika dot ganganna at oracle dot com
                   ` (11 preceding siblings ...)
  2009-01-09 16:58 ` sebor at roguewave dot com
@ 2009-01-12 10:48 ` radhika dot ganganna at oracle dot com
  2009-01-12 11:11 ` paolo dot carlini at oracle dot com
  2009-08-03 20:16 ` paolo dot carlini at oracle dot com
  14 siblings, 0 replies; 16+ messages in thread
From: radhika dot ganganna at oracle dot com @ 2009-01-12 10:48 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #13 from radhika dot ganganna at oracle dot com  2009-01-12 10:48 -------
Hi,

Even if I avoid using our implementation of codecvt, i still get the same
output of missing data. 

Regards,
Radhika


-- 

radhika dot ganganna at oracle dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |UNCONFIRMED
         Resolution|INVALID                     |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38741


^ permalink raw reply	[flat|nested] 16+ messages in thread

* [Bug libstdc++/38741] Unable to write data to wofstream
  2009-01-06  9:47 [Bug c++/38741] New: Unable to write data to wofstream radhika dot ganganna at oracle dot com
                   ` (12 preceding siblings ...)
  2009-01-12 10:48 ` radhika dot ganganna at oracle dot com
@ 2009-01-12 11:11 ` paolo dot carlini at oracle dot com
  2009-08-03 20:16 ` paolo dot carlini at oracle dot com
  14 siblings, 0 replies; 16+ messages in thread
From: paolo dot carlini at oracle dot com @ 2009-01-12 11:11 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #14 from paolo dot carlini at oracle dot com  2009-01-12 11:11 -------
Then, post your new (correct, I hope) codecvt


-- 

paolo dot carlini at oracle dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |WAITING


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38741


^ permalink raw reply	[flat|nested] 16+ messages in thread

* [Bug libstdc++/38741] Unable to write data to wofstream
  2009-01-06  9:47 [Bug c++/38741] New: Unable to write data to wofstream radhika dot ganganna at oracle dot com
                   ` (13 preceding siblings ...)
  2009-01-12 11:11 ` paolo dot carlini at oracle dot com
@ 2009-08-03 20:16 ` paolo dot carlini at oracle dot com
  14 siblings, 0 replies; 16+ messages in thread
From: paolo dot carlini at oracle dot com @ 2009-08-03 20:16 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #15 from paolo dot carlini at oracle dot com  2009-08-03 20:16 -------
Feedback not forthcoming.


-- 

paolo dot carlini at oracle dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|WAITING                     |RESOLVED
         Resolution|                            |INVALID


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38741


^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2009-08-03 20:16 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-01-06  9:47 [Bug c++/38741] New: Unable to write data to wofstream radhika dot ganganna at oracle dot com
2009-01-06 20:23 ` [Bug libstdc++/38741] " pinskia at gcc dot gnu dot org
2009-01-07  6:35 ` radhika dot ganganna at oracle dot com
2009-01-07 10:58 ` radhika dot ganganna at oracle dot com
2009-01-08  8:58 ` radhika dot ganganna at oracle dot com
2009-01-08  8:59 ` radhika dot ganganna at oracle dot com
2009-01-08 14:36 ` paolo dot carlini at oracle dot com
2009-01-09  4:44 ` radhika dot ganganna at oracle dot com
2009-01-09  9:41 ` paolo dot carlini at oracle dot com
2009-01-09  9:56 ` paolo dot carlini at oracle dot com
2009-01-09 10:09 ` radhika dot ganganna at oracle dot com
2009-01-09 10:15 ` paolo dot carlini at oracle dot com
2009-01-09 16:58 ` sebor at roguewave dot com
2009-01-12 10:48 ` radhika dot ganganna at oracle dot com
2009-01-12 11:11 ` paolo dot carlini at oracle dot com
2009-08-03 20:16 ` paolo dot carlini at oracle dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).