Connecting Tech Pros Worldwide Forums | Help | Site Map

Suspected compiler bug (was: Using different instances of the 'std::basic_string<>' template)

Hendrik Schober
Guest
 
Posts: n/a
#1: Nov 16 '05
Hi,

I had originally suspected this to be a bug
in the std lib, that's why I started a thred
in the STL newsgroup. However, it seems as if
it is a compiler bug, so I'm transfering it to
here.
The original code was this:

----- Original Message -----
From: "Hendrik Schober" <SpamTrap@gmx.de>
Newsgroups: microsoft.public.vc.stl
Sent: Wednesday, October 29, 2003 10:04 PM
Subject: Using different instances of the 'std::basic_string<>' template


[...]

#include <iostream>
#include <fstream>
#include <string>
#include <cstdlib>

template< typename T >
struct CTraits {

template< typename T >
struct char_traits : public std::char_traits<char> {};

typedef
std::basic_string< char, char_traits<T>, std::allocator<char> >
string;

typedef
std::basic_ofstream< char, char_traits<T> >
ofstream;
};

struct tag {};

int main()
{
std::string sstr = "Hello, world!";
CTraits<tag>::string us( sstr.begin(), sstr.end() );
CTraits<tag>::ofstream ofs("c:\\test.txt");
if( !ofs ) {std::cerr << "Cannot open file!\n";std::abort();}

ofs << us;
if( !ofs ) {std::cerr << "Cannot write to file!\n";std::abort();}

return 0;
}


[...]

This is a piece from the discussion about this:

Bo Persson <bop2@telia.com> wrote:[color=blue]
> "Hendrik Schober" <SpamTrap@gmx.de> skrev i meddelandet
> news:OD0OOGtnDHA.2628@TK2MSFTNGP10.phx.gbl...[color=green]
> > Bo Persson <bop2@telia.com> wrote:[color=darkred]
> > > [...]
> > > Could be a bug in the compiler. :-)[/color]
> >
> > I'd rather suspect the std lib. That's why
> > I posted here.[/color]
>
> Yes, but I get the same error with both Dinkumware and my private
> (gasp!) implementation of the standard library. It occurs at this line
> inside basic_ofstream
>
> virtual int_type overflow(int_type _MetaChar =
> traits_type::eof())
> {
>
> where traits_type is a typedef for a template parameter, from a
> typedef for a specialization of std::basic_filestream using a
> templated class that inherits from std::char_traits. Or something :-)
>
> It can't resolve eof() because it thinks that traits_type (expanded to
> char_traits<tag>) doesn't look like a class or namespace.
>
>
> Also, if we move "our" char_traits outside CTraits, it compiles.
>
>
> Bo Persson[/color]


Especially the last sentence strongly hints
at a compiler bug.

Schobi

[crossposted and f'up set to microsoft.public.dotnet.languages.vc]

--
SpamTrap@gmx.de is never read
I'm Schobi at suespammers org

"And why should I know better by now/When I'm old enough not to?"
Beth Orton



David Lowndes
Guest
 
Posts: n/a
#2: Nov 16 '05

re: Suspected compiler bug (was: Using different instances of the 'std::basic_string<>' template)


>I had originally suspected this to be a bug[color=blue]
>in the std lib, that's why I started a thred
>in the STL newsgroup. However, it seems as if
>it is a compiler bug[/color]

It looks like you might be right.

FWIW, I can repro the problem with VS7.1, but it builds fine with the
Whidbey alpha compiler.

Dave
--
MVP VC++ FAQ: http://www.mvps.org/vcfaq
Hendrik Schober
Guest
 
Posts: n/a
#3: Nov 16 '05

re: Suspected compiler bug (was: Using different instances of the 'std::basic_string<>' template)


David Lowndes <davidl@mvps.org> wrote:[color=blue][color=green]
> > I had originally suspected this to be a bug
> > in the std lib, that's why I started a thred
> > in the STL newsgroup. However, it seems as if
> > it is a compiler bug[/color]
>
> It looks like you might be right.
>
> FWIW, I can repro the problem with VS7.1, but it builds fine with the
> Whidbey alpha compiler.[/color]

I don't think I can expect a soon fix for that?
<sigh>
This breaks a lot of my code which compiles using
CodeWarrior and GCC. I'm not sure how (if) I can
work around this.
[color=blue]
> Dave[/color]

Schobi

--
SpamTrap@gmx.de is never read
I'm Schobi at suespammers org

"And why should I know better by now/When I'm old enough not to?"
Beth Orton


David Lowndes
Guest
 
Posts: n/a
#4: Nov 16 '05

re: Suspected compiler bug (was: Using different instances of the 'std::basic_string<>' template)


> I don't think I can expect a soon fix for that?

I really don't know.

If you report the problem to MS product support, and there isn't a
work-around, they may have a bug fix available (that's not fully
tested).

Dave
--
MVP VC++ FAQ: http://www.mvps.org/vcfaq
Hendrik Schober
Guest
 
Posts: n/a
#5: Nov 16 '05

re: Suspected compiler bug (was: Using different instances of the 'std::basic_string<>' template)


David Lowndes <davidl@mvps.org> wrote:[color=blue][color=green]
> > I don't think I can expect a soon fix for that?[/color]
>
> I really don't know.
>
> If you report the problem to MS product support, and there isn't a
> work-around, they may have a bug fix available (that's not fully
> tested).[/color]

Mhmm. How would I have to start to do this?
[color=blue]
> Dave[/color]

Schobi

--
SpamTrap@gmx.de is never read
I'm Schobi at suespammers org

"And why should I know better by now/When I'm old enough not to?"
Beth Orton


David Lowndes
Guest
 
Posts: n/a
#6: Nov 16 '05

re: Suspected compiler bug (was: Using different instances of the 'std::basic_string<>' template)


>> If you report the problem to MS product support, and there isn't a[color=blue][color=green]
>> work-around, they may have a bug fix available (that's not fully
>> tested).[/color]
>
> Mhmm. How would I have to start to do this?[/color]

I don't know of any other way other than to phone your regional MS
Product Support phone number.

Dave
--
MVP VC++ FAQ: http://www.mvps.org/vcfaq
Closed Thread