This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/49759] New: std::streampos == int should be ambiguous
- From: "mathieu.malaterre at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Sat, 16 Jul 2011 07:53:31 +0000
- Subject: [Bug c++/49759] New: std::streampos == int should be ambiguous
- Auto-submitted: auto-generated
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49759
Summary: std::streampos == int should be ambiguous
Product: gcc
Version: 4.4.5
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: mathieu.malaterre@gmail.com
I believe the following code should not compile:
#include <fstream>
int main()
{
std::ofstream f( "bla.txt" );
std::ifstream is( "bla.txt" );
if( is.tellg() == 0 ) {}
return 0;
}
the overload for 'operator==' is ambiguous and should be reported. Eg:
line 7: error: more than one operator "==" matches these operands:
built-in operator "arithmetic == arithmetic"
function "std::operator==(const std::fpos<mbstate_t> &, const
std::fpos<mbstate_t> &)"
operand types are: std::streampos == int
if( is.tellg() == 0 ) {}
^
or
error: ambiguous overload for 'operator==' in
'((std::istream*)is)->std::basic_istream<_CharT, _Traits>::tellg [with _CharT =
char, _Traits = std::char_traits<char>]() == 0'
note: candidates are: operator==(std::streamoff, int) <built-in>
/Developer/SDKs/MacOSX10.5.sdk/usr/include/c++/4.0.0/bits/postypes.h:138: note:
bool std::fpos<_StateT>::operator==(const std::fpos<_StateT>&)
const [with _StateT = __mbstate_t]