This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
GCC 3.0.2: errno conflict.
- From: "Maxim Dementiev" <max at e-soft dot ru>
- To: <gcc at gcc dot gnu dot org>
- Date: Fri, 14 Dec 2001 18:52:42 +0300
- Subject: GCC 3.0.2: errno conflict.
Excuse me if this bug is wellknown for peaple.
This code copile with error by g++ 3.0.2 on Linux 2.2.19 (i386).
(See commented line below.)
If rename "errno" to "errno1" - all works fine.
Is it a bug?
======== start ========
namespace mpd
{
class ErrnoException
{
public:
ErrnoException( const char * const a,
const int l,
const int r,
const int e ) throw() :
file( a ), line( l ), retval( r ), errno( e ) { }
const char * const file;
const int line;
const int retval;
const int errno;
};
}
#include <iostream>
using ::std::cout;
using ::std::endl;
using ::mpd::ErrnoException;
void func( const int a ) throw( ErrnoException )
{
if( a == 2 ) throw ErrnoException( __FILE__, __LINE__, 0, 2 );
return;
}
int main( int n, char ** a )
{
for( int i=1; i<4; i++ )
try
{
func( i );
cout << i << endl;
}
catch( ErrnoException e )
{
cout << "Exception in file " << e.file << " at line #" << e.line <<
", errno = " << e.errno << "." << endl; // <-- error!
}
return 0;
}
======== end ========
Maxim Dementiev.