Web Images Videos Maps News Shopping Gmail more »
Recently Visited Groups | Help | Sign in
Google Groups Home
char_traits bug
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  11 messages - Expand all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Jason Winnebeck  
View profile  
 More options Feb 14 2004, 4:54 pm
Newsgroups: microsoft.public.vc.stl
From: Jason Winnebeck <gill...@mail.rit.nspam.edu>
Date: Sat, 14 Feb 2004 16:53:04 -0500
Local: Sat, Feb 14 2004 4:53 pm
Subject: char_traits bug
I haven't found any other place you can report a bug with Visual Studio,
so I figured I'd try here, although I don't think any MS people read these.

I'm deriving a class from the templated std::streambuf.  In MSVC.NET
2002 and also in GCC 3 and te Comeau compiler, this code compiles.
However in MSVC.NET 2003 alone does it not compile.

I had to implement a small workaround only for MSVC.NET 2003.  The code
for the class is as follows:
class goutbuf : public std::streambuf {
public:
   goutbuf();
   ~goutbuf();

   /**
    * If set, the next output will be an mlprintf instead of a mprintf, with
    * the specified coordinates.
    */
   void setNextWriteLoc(int x, int y);

protected:
   int sync();
   void flush_output();

#if (_MSC_VER == 1310 )
   //While still technically correct and valid, it's not quite as robust
as the
   //next line because this makes the assumption on what traits_type is
defined
   //as.
   int_type overflow(int_type meta = std::char_traits<char>::eof());
#else
   //For some reason, in MSVC.NET 2003 alone (not 2002), this line generates
   //the following error:
   //error C2653: 'char_traits<char>' : is not a class or namespace name
   int_type overflow(int_type meta = traits_type::eof());
#endif

   std::streamsize xsputn(const char_type *ptr, std::streamsize count);

private:
   char* buf;

   int x; //the next coords to write to, if not -1.
   int y;

};

This is part of the header file.  The class is in the namespace
GNE::Console, and there is another class in the header.

Jason Winnebeck


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Carl Daniel [VC++ MVP]  
View profile  
 More options Feb 14 2004, 9:08 pm
Newsgroups: microsoft.public.vc.stl
From: "Carl Daniel [VC++ MVP]" <cpdaniel_remove_this_and_nos...@mvps.org.nospam>
Date: Sat, 14 Feb 2004 18:07:19 -0800
Local: Sat, Feb 14 2004 9:07 pm
Subject: Re: char_traits bug

Jason Winnebeck wrote:
> I haven't found any other place you can report a bug with Visual
> Studio,
> so I figured I'd try here, although I don't think any MS people read
> these.

They do.

> I'm deriving a class from the templated std::streambuf.  In MSVC.NET
> 2002 and also in GCC 3 and te Comeau compiler, this code compiles.
> However in MSVC.NET 2003 alone does it not compile.

It would help if you could post a complete example that illustrates the
behavior you're reporting as a bug.   I assume you did #include <string>?
I'm not sure that std::char_traits is required to be defined if you haven't
explicitly included <string>

-cd


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jason Winnebeck  
View profile  
 More options Feb 15 2004, 3:51 am
Newsgroups: microsoft.public.vc.stl
From: Jason Winnebeck <gill...@mail.rit.nspam.edu>
Date: Sun, 15 Feb 2004 03:49:38 -0500
Local: Sun, Feb 15 2004 3:49 am
Subject: Re: char_traits bug
Carl Daniel [VC++ MVP] wrote:

> It would help if you could post a complete example that illustrates the
> behavior you're reporting as a bug.   I assume you did #include <string>?
> I'm not sure that std::char_traits is required to be defined if you haven't
> explicitly included <string>

I would expect that to be the first question someone would ask me, and I have
two very good answers for this.

The first answer is, if you look at the previous code with the workaround,
switching to std::char_traits<char> does work.

The second answer is that I am not using char_traits at all in the "correct"
code (the second part of the #if).  I'm using std::streambuf::traits_type.
And <streambuf> is included, espically seeing as goutbuf is declared from
streambuf.

If we look in the standard, std::streambuf::traits_type is a member (a
typedef) of the std::streambuf class, and its definition is
std::char_traits<char> for std::streambuf (which is std::basic_streambuf<char,
std::char_traits<char> >) as defined by 27.5 of the standard.  27.5.2 defines
the traits_type typedef for std::streambuf.

The code using traits_type compiles on MSVC.NET 2002, GCC 3, and Comeau.  I
can't see a reason why it should not work by the standard (and thus for 2003).

Perhaps, though, I will try including it.  But as I said, replacing the
typedef'd element of streambuf with its definition fixes the problem, which
is, I believe, to be a very clear sign that something is wrong.

If
typedef A B;
And if:
B x;
gives an error that "A" is not defined, but
A x;
does work, I would say this is not right.

Jason Winnebeck


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Carl Daniel [VC++ MVP]  
View profile  
 More options Feb 15 2004, 1:29 pm
Newsgroups: microsoft.public.vc.stl
From: "Carl Daniel [VC++ MVP]" <cpdaniel_remove_this_and_nos...@mvps.org.nospam>
Date: Sun, 15 Feb 2004 10:29:25 -0800
Local: Sun, Feb 15 2004 1:29 pm
Subject: Re: char_traits bug

Jason Winnebeck wrote:
> Carl Daniel [VC++ MVP] wrote:
>> It would help if you could post a complete example that illustrates
>> the behavior you're reporting as a bug.   I assume you did #include
>> <string>? I'm not sure that std::char_traits is required to be
>> defined if you haven't explicitly included <string>
> Perhaps, though, I will try including it.  But as I said, replacing
> the typedef'd element of streambuf with its definition fixes the
> problem, which is, I believe, to be a very clear sign that something
> is wrong.

It may well be.  Without a complete example it's much harder to speculate.
With a complete example it's much more likely that a bug, if there is one,
will get fixed.  FWIW it does sound like a bug to me.

-cd


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
tom_usenet  
View profile  
 More options Feb 16 2004, 4:46 am
Newsgroups: microsoft.public.vc.stl
From: tom_usenet <tom_use...@hotmail.com>
Date: Mon, 16 Feb 2004 09:49:59 +0000
Local: Mon, Feb 16 2004 4:49 am
Subject: Re: char_traits bug
On Sun, 15 Feb 2004 10:29:25 -0800, "Carl Daniel [VC++ MVP]"

This does it:

#include <streambuf>

class goutbuf : public std::streambuf {
protected:
   int_type overflow(int_type meta = traits_type::eof());

};

Tom

C++ FAQ: http://www.parashift.com/c++-faq-lite/
C FAQ: http://www.eskimo.com/~scs/C-faq/top.html


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Carl Daniel [VC++ MVP]  
View profile  
 More options Feb 16 2004, 10:37 am
Newsgroups: microsoft.public.vc.stl
From: "Carl Daniel [VC++ MVP]" <cpdaniel_remove_this_and_nos...@mvps.org.nospam>
Date: Mon, 16 Feb 2004 07:36:26 -0800
Local: Mon, Feb 16 2004 10:36 am
Subject: Re: char_traits bug

tom_usenet wrote:
> This does it:

> #include <streambuf>

> class goutbuf : public std::streambuf {
> protected:
>    int_type overflow(int_type meta = traits_type::eof());
> };

Tom -

Thanks for finding a tiny repro!

Jason -

This appears to be fixed in the Whidbey alpha.  If this is causing you
significant problems in yoiur production work, you should contact Product
Support Services.

-cd


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jason Winnebeck  
View profile  
 More options Feb 16 2004, 3:31 pm
Newsgroups: microsoft.public.vc.stl
From: Jason Winnebeck <gill...@mail.rit.nspam.edu>
Date: Mon, 16 Feb 2004 15:29:21 -0500
Local: Mon, Feb 16 2004 3:29 pm
Subject: Re: char_traits bug
Carl Daniel [VC++ MVP] wrote:

Wow thanks for the replies.  It's nice to know that there is somewhere
to report these things.  I wonder if I should try to find a repro case
for a bug I found in the optimizer.  I found an issue where I wrote a
random number generator and the function was inlined very incorrectly.
The problem was solved by turning off inlining for that function alone.
   (or was also solved by turning off whole program optimizations as the
RNG function was in another file). I believe IIRC the statements were
reordered improperly such that the integer code ran only once for all
the calls and the floating point code was run multiple times, so that if
I called my RNG 4 times and it returned let's say 20, and I called
"getrnd()/2" four times in a row, I'd get 20, 10, 5, 2.5.

But I digress, so if I want to do that I will probably file it on a
different VC newsgroup after narrowing the code down.

As for the char_traits bug, it is bothersome, but I have to deal with it
anyway as the code is in a library distributed as source code, and when
using that preprocessor test it works fine.

Thanks,
Jason Winnebeck


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Carl Daniel [VC++ MVP]  
View profile  
 More options Feb 16 2004, 4:05 pm
Newsgroups: microsoft.public.vc.stl
From: "Carl Daniel [VC++ MVP]" <cpdaniel_remove_this_and_nos...@mvps.org.nospam>
Date: Mon, 16 Feb 2004 13:03:46 -0800
Local: Mon, Feb 16 2004 4:03 pm
Subject: Re: char_traits bug

Jason Winnebeck wrote:
> Wow thanks for the replies.  It's nice to know that there is somewhere
> to report these things.
> I wonder if I should try to find a repro case
> for a bug I found in the optimizer.  I found an issue where I wrote a
> random number generator and the function was inlined very incorrectly.

If you can produce a repro, please post it.  The VC team is usually very
interested in fixing codegen bugs, but having a repro is for all practical
purposes a necessity.

> The problem was solved by turning off inlining for that function
>    alone. (or was also solved by turning off whole program
> optimizations as the
> RNG function was in another file). I believe IIRC the statements were
> reordered improperly such that the integer code ran only once for all
> the calls and the floating point code was run multiple times, so that
> if
> I called my RNG 4 times and it returned let's say 20, and I called
> "getrnd()/2" four times in a row, I'd get 20, 10, 5, 2.5.

It might be that your code exhibited undefined behavior too - a repro will
tell.

> But I digress, so if I want to do that I will probably file it on a
> different VC newsgroup after narrowing the code down.

I'd suggest posting it to microsoft.public.vc.language.

> As for the char_traits bug, it is bothersome, but I have to deal with
> it anyway as the code is in a library distributed as source code, and
> when using that preprocessor test it works fine.

OK.

-cd


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
tom_usenet  
View profile  
 More options Feb 19 2004, 5:37 am
Newsgroups: microsoft.public.vc.stl
From: tom_usenet <tom_use...@hotmail.com>
Date: Thu, 19 Feb 2004 10:41:40 +0000
Local: Thurs, Feb 19 2004 5:41 am
Subject: Re: char_traits bug
On Mon, 16 Feb 2004 15:29:21 -0500, Jason Winnebeck

<gill...@mail.rit.nspam.edu> wrote:
>As for the char_traits bug, it is bothersome, but I have to deal with it
>anyway as the code is in a library distributed as source code, and when
>using that preprocessor test it works fine.

This simple workaround seems to fix the problem:

#include <streambuf>

class goutbuf : public std::streambuf {
protected:
    int_type overflow(int_type meta =
std::streambuf::traits_type::eof());

};

Tom

C++ FAQ: http://www.parashift.com/c++-faq-lite/
C FAQ: http://www.eskimo.com/~scs/C-faq/top.html


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jason Winnebeck  
View profile  
 More options Feb 19 2004, 8:30 am
Newsgroups: microsoft.public.vc.stl
From: Jason Winnebeck <gill...@mail.rit.nspam.edu>
Date: Thu, 19 Feb 2004 08:27:12 -0500
Local: Thurs, Feb 19 2004 8:27 am
Subject: Re: char_traits bug

tom_usenet wrote:
> This simple workaround seems to fix the problem:
>     int_type overflow(int_type meta =
> std::streambuf::traits_type::eof());
> };

Oh I will try that one out tonight.  That would allow for me to get rid
of the #if preprocessor statement, and while although overly redundant,
it is still as correct as using traits_type, I believe.  My workaround
invovled using char_traits<char> directly which should always be correct
since it is specified in the standard, but I still feel better using the
more generic approach.

Jason


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Kai Henning  
View profile  
 More options Feb 20 2004, 3:14 am
Newsgroups: microsoft.public.vc.stl
From: "Kai Henning" <henn...@aut.tu-cottbus.de>
Date: Fri, 20 Feb 2004 09:12:11 +0100
Local: Fri, Feb 20 2004 3:12 am
Subject: Re: char_traits bug
It's a bug in MSVC.NET. Compile the following code. It produces the same
error.

#include <limits>
#undef max

template < typename T >
class A
{
protected:
    typedef std::numeric_limits< T >        MinMaxTy;
private:
    T t_;
public:
    A(const T t= MinMaxTy::max()) : t_(t) {}

};

template < typename T >
class AA : public A< T >
{
    typedef A< T >                              inherited;
    typedef typename inherited::MinMaxTy        MinMaxTy;
public:
    AA(const T t= MinMaxTy::max()) : inherited(t) {}

};

int main()
{
    AA< int > a;

}

Kai Henning

"Jason Winnebeck" <gill...@mail.rit.nspam.edu> schrieb im Newsbeitrag
news:#DlRuT08DHA.2752@TK2MSFTNGP09.phx.gbl...


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google