Bug 16854 - streams missing "long long" specializations on Tru64
Summary: streams missing "long long" specializations on Tru64
Status: RESOLVED WONTFIX
Alias: None
Product: gcc
Classification: Unclassified
Component: libstdc++ (show other bugs)
Version: 3.3.4
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-08-02 13:21 UTC by papadopo
Modified: 2005-07-23 22:49 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments
compile/link this file on Tru64 to reproduce the bug (87 bytes, text/plain)
2004-08-02 13:24 UTC, papadopo
Details
Local hack (1002 bytes, patch)
2004-08-02 14:08 UTC, Paolo Carlini
Details | Diff
Amended (1.05 KB, patch)
2004-08-02 14:10 UTC, Paolo Carlini
Details | Diff
Sorry, this one should be complete (1.44 KB, patch)
2004-08-02 14:15 UTC, Paolo Carlini
Details | Diff
Shish, this one it is (1.92 KB, patch)
2004-08-02 14:21 UTC, Paolo Carlini
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description papadopo 2004-08-02 13:21:48 UTC
Hi,

The attached source makes use of the "long long" type which is defined by the
compiler. Unfortunately there's no specialization of stream input and output
operators for "long long":

$ cat > foo.cc
#include <iostream>
using namespace std;
int main() {
  long long i;
  cout << i << endl;
}
$ 
$ g++ foo.cc
foo.cc: In function `int main()':
foo.cc:5: error: ambiguous overload for 'operator<<' in 'std::cout << i'
/usr/local/include/c++/3.3.4/bits/ostream.tcc:63: error: candidates are:
   std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT,
   _Traits>::operator<<(std::basic_ostream<_CharT,
   _Traits>&(*)(std::basic_ostream<_CharT, _Traits>&)) [with _CharT = char,
   _Traits = std::char_traits<char>] <near match>
/usr/local/include/c++/3.3.4/bits/ostream.tcc:74: error:
   std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT,
   _Traits>::operator<<(std::basic_ios<_CharT,
   _Traits>&(*)(std::basic_ios<_CharT, _Traits>&)) [with _CharT = char, _Traits
   = std::char_traits<char>] <near match>
/usr/local/include/c++/3.3.4/bits/ostream.tcc:86: error:
   std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT,
   _Traits>::operator<<(std::ios_base&(*)(std::ios_base&)) [with _CharT = char,
   _Traits = std::char_traits<char>] <near match>
/usr/local/include/c++/3.3.4/bits/ostream.tcc:122: error:
   std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT,
   _Traits>::operator<<(long int) [with _CharT = char, _Traits =
   std::char_traits<char>]
/usr/local/include/c++/3.3.4/bits/ostream.tcc:156: error:
   std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT,
   _Traits>::operator<<(long unsigned int) [with _CharT = char, _Traits =
   std::char_traits<char>]
/usr/local/include/c++/3.3.4/bits/ostream.tcc:98: error:
   std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT,
   _Traits>::operator<<(bool) [with _CharT = char, _Traits =
   std::char_traits<char>]
/usr/local/include/c++/3.3.4/ostream:178: error:
   std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT,
   _Traits>::operator<<(short int) [with _CharT = char, _Traits =
   std::char_traits<char>]
/usr/local/include/c++/3.3.4/ostream:189: error:
   std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT,
   _Traits>::operator<<(short unsigned int) [with _CharT = char, _Traits =
   std::char_traits<char>]
/usr/local/include/c++/3.3.4/ostream:193: error:
   std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT,
   _Traits>::operator<<(int) [with _CharT = char, _Traits =
   std::char_traits<char>]
/usr/local/include/c++/3.3.4/ostream:204: error:
   std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT,
   _Traits>::operator<<(unsigned int) [with _CharT = char, _Traits =
   std::char_traits<char>]
/usr/local/include/c++/3.3.4/bits/ostream.tcc:241: error:
   std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT,
   _Traits>::operator<<(double) [with _CharT = char, _Traits =
   std::char_traits<char>]
/usr/local/include/c++/3.3.4/ostream:219: error:
   std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT,
   _Traits>::operator<<(float) [with _CharT = char, _Traits =
   std::char_traits<char>]
/usr/local/include/c++/3.3.4/bits/ostream.tcc:265: error:
   std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT,
   _Traits>::operator<<(long double) [with _CharT = char, _Traits =
   std::char_traits<char>]
/usr/local/include/c++/3.3.4/bits/ostream.tcc:289: error:
   std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT,
   _Traits>::operator<<(const void*) [with _CharT = char, _Traits =
   std::char_traits<char>] <near match>
/usr/local/include/c++/3.3.4/bits/ostream.tcc:313: error:
   std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT,
   _Traits>::operator<<(std::basic_streambuf<_CharT, _Traits>*) [with _CharT =
   char, _Traits = std::char_traits<char>] <near match>
/usr/local/include/c++/3.3.4/ostream:436: error:
   std::basic_ostream<_CharT, _Traits>&
   std::operator<<(std::basic_ostream<_CharT, _Traits>&, char) [with _CharT =
   char, _Traits = std::char_traits<char>]
/usr/local/include/c++/3.3.4/bits/ostream.tcc:512: error:
   std::basic_ostream<char, _Traits>& std::operator<<(std::basic_ostream<char,
   _Traits>&, char) [with _Traits = std::char_traits<char>]
/usr/local/include/c++/3.3.4/ostream:447: error:
   std::basic_ostream<char, _Traits>& std::operator<<(std::basic_ostream<char,
   _Traits>&, signed char) [with _Traits = std::char_traits<char>]
/usr/local/include/c++/3.3.4/ostream:452: error:
   std::basic_ostream<char, _Traits>& std::operator<<(std::basic_ostream<char,
   _Traits>&, unsigned char) [with _Traits = std::char_traits<char>]
/usr/local/include/c++/3.3.4/bits/ostream.tcc:572: error:
   std::basic_ostream<_CharT, _Traits>&
   std::operator<<(std::basic_ostream<_CharT, _Traits>&, const char*) [with
   _CharT = char, _Traits = std::char_traits<char>] <near match>
/usr/local/include/c++/3.3.4/bits/ostream.tcc:616: error:
   std::basic_ostream<char, _Traits>& std::operator<<(std::basic_ostream<char,
   _Traits>&, const char*) [with _Traits = std::char_traits<char>] <near match>
/usr/local/include/c++/3.3.4/ostream:486: error:
   std::basic_ostream<char, _Traits>& std::operator<<(std::basic_ostream<char,
   _Traits>&, const signed char*) [with _Traits = std::char_traits<char>] <near
   match>
/usr/local/include/c++/3.3.4/ostream:491: error:
   std::basic_ostream<char, _Traits>& std::operator<<(std::basic_ostream<char,
   _Traits>&, const unsigned char*) [with _Traits = std::char_traits<char>]
   <near match>
$ 


That's because in header files <istream> and <ostream> the relevant functions
are protected by _GLIBCPP_USE_LONG_LONG:

	#ifdef _GLIBCPP_USE_LONG_LONG
	      __istream_type& 
 	     operator>>(long long& __n);
	
 	     __istream_type& 
 	     operator>>(unsigned long long& __n);
	#endif

and:

	#ifdef _GLIBCPP_USE_LONG_LONG
	      __ostream_type& 
	      operator<<(long long __n);
	
	      __ostream_type& 
	      operator<<(unsigned long long __n);
	#endif

Why is _GLIBCPP_USE_LONG_LONG not defined on Tru64? Type "long long" is legal
and distinct from "long". SHouldn't it be defined?
Comment 1 papadopo 2004-08-02 13:24:32 UTC
Created attachment 6865 [details]
compile/link this file on Tru64 to reproduce the bug
Comment 2 Paolo Carlini 2004-08-02 13:40:08 UTC
PR libstdc++/16210 is related to this one, but not identical: for gcc3.4.x we
have been able to remove completely the autoconf test for _GLIBCPP_USE_LONG_LONG 
since no libc functions are used anymore to support I/O of long long types.

On the other hand, if long long support ends up being disabled on Tru64 with
gcc3.3.x, it's because the required strto(u)ll functions are not available there:
we can't do much about this, unfortunately.

Can you confirm the latter analysis?
Comment 3 papadopo 2004-08-02 13:55:16 UTC
I can confirm strto(u)ll are not available on Tru64. However that's not a
problem since you can use strto(u)l instead.

Remember, Tru64 is a 64-bit system (64-bit *only* as opposed to other systems
that used to be 32-bit, have moved to 64-bit, and run both 32-bit and 64-bit
programs).
Comment 4 Paolo Carlini 2004-08-02 14:07:03 UTC
I see... I hope you will understand that at this point in time, it would be too
much work taking care of this special case in the 3.3.x branch. Sorry. Could you
possibly hack locally your tree? I'm attaching a draft patch.
Comment 5 Paolo Carlini 2004-08-02 14:08:02 UTC
Created attachment 6866 [details]
Local hack
Comment 6 Paolo Carlini 2004-08-02 14:10:09 UTC
Created attachment 6867 [details]
Amended
Comment 7 Paolo Carlini 2004-08-02 14:15:41 UTC
Created attachment 6868 [details]
Sorry, this one should be complete
Comment 8 papadopo 2004-08-02 14:19:00 UTC
I understand, I was just reporting the problem so that it can be fixed in gcc
3.4 or 3.5.

Unfortunately I don't have root access on the Tru64 machine to modify the
installed GCC compiler, and it would take too much time to build my own version
of it - I'm not even certain I have enough space on my home directory. I worked
around the problem in my code by typedef'ing to "long" instead of "long long" on
Tru64.
Comment 9 Paolo Carlini 2004-08-02 14:21:17 UTC
Created attachment 6869 [details]
Shish, this one it is
Comment 10 papadopo 2004-08-02 14:21:31 UTC
By the way, will this be fixed in 3.5, as part of PR libstdc++/16210 or
independently of it?
Comment 11 Paolo Carlini 2004-08-02 14:22:48 UTC
Yes, it's already fixed for 3.5 and 3.4.2.