This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: Patch for too lenient handling of pointer-to-member conversions
- To: mmitchell at usa dot net
- Subject: Re: Patch for too lenient handling of pointer-to-member conversions
- From: Klaus-Georg Adams <Klaus-Georg dot Adams at chemie dot uni-karlsruhe dot de>
- Date: Fri, 13 Feb 1998 14:00:55 +0100
- Cc: egcs-bugs at cygnus dot com
Hi Mark,
Does your patch
Wed Feb 11 15:54:18 1998 Mark Mitchell
* typeck.c (build_ptrmemfunc): Typecheck pointer-to-member
conversions.
flag cases like the following:
//
// Demonstrate the lack of checking in assignment to member
// function pointers.
#include <iostream.h>
struct t {
void cheat( int& i ) { ++i; }
};
int main()
{
void (t::*member)( const int& ) = &t::cheat;
t t2;
const int i=1;
int j=1;
(t2.*member)( i );
(t2.*member)( j );
cout << " i is: " << i << endl
<< " j is: " << j << endl;
return 0;
}
or
//
// Demonstrate the lack of checking in assignment to function
// pointers. Note: gcc flags this, g++ doesn't.
#include <stdio.h>
void cheat( int* i ) { ++(*i); }
int main()
{
void (*cheater)( const int* ) = &cheat;
const int i=1;
int j=1;
(*cheater)( &i );
(*cheater)( &j );
printf( " i is: %i\n j is: %i\n", i, j );
return 0;
}
-- kga
-------------------------------------------------------------------------
Klaus-Georg Adams Email: Klaus-Georg.Adams@chemie.uni-karlsruhe.de
Institut f. Anorg. Chemie II Tel: 0721 608 3485
Uni Karlsruhe
-------------------------------------------------------------------------