Bug 65211

Summary: Bad: iostream::traits_type is ambiguous
Product: [Retired] Red Hat Linux Reporter: Need Real Name <dens>
Component: libstdc++Assignee: Jakub Jelinek <jakub>
Status: CLOSED NOTABUG QA Contact:
Severity: medium Docs Contact:
Priority: medium    
Version: 7.2CC: dens
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2004-10-01 15:13:00 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Description Need Real Name 2002-05-20 12:41:17 UTC
Description of Problem:

When I try to compile following code:

// ... skipped
 typedef STD basic_iostream<Char,It> Iostr;
 Iostr::traits_type * some = (It*)0;
// ... skipped

Compiler tells me that member `traits_type' is ambiguous and candidates are
placed in basic_ostream and basic_istream.

I know that
C++ standard & describes public types of classes 
basic_istream & basic_ostream such as:
// Types (inherited from basic_ios (27.4.4)):
    typedef charT  char_type;
    typedef typename traits::int_type int_type;
    typedef typename traits::pos_type       pos_type;
    typedef typename traits::off_type       off_type;
    typedef traits traits_type;

but I believe that these typedefs can be placed in basic_ios only. 
Version-Release number of selected component (if applicable):

How Reproducible:
Try to compile source code which contains refference to iostream::traits_type

Steps to Reproduce:
1.  Try to compile source code which contains refference to iostream::traits_type

Actual Results:
request for member `traits_type' is ambiguous
/usr/include/g++-v3/bits/std_ostream.h:54: candidates are: typedef struct 
   std::char_traits<char> std::basic_ostream<char, std::char_traits<char> 
/usr/include/g++-v3/bits/std_istream.h:54:                 typedef struct 
   std::char_traits<char> std::basic_istream<char, std::char_traits<char> 

Expected Results:
Code should be compiled without any errors.

Additional Information:

Comment 1 Benjamin Kosnik 2004-10-01 15:13:00 UTC
Dunno what's up with this bug, report itself is ambiguous. Please
reopen and provide source to your problem if you feel this is still an
active issue.

This works with gcc-3.3.x and gcc-3.4.x:

#include <iostream>

int main()
  typedef std::basic_iostream<char, std::char_traits<char> > Iostr;
  Iostr::traits_type* some = NULL;