g++ implicit function to function pointer decay bug

Nathan Sidwell nathan@acm.org
Thu Jan 7 05:12:00 GMT 1999


Hi,
shouldn't there be a diagnostic with the following program? It's
implicitly converting from void (*)(int *) to void (*)(void *).
These are not compatible types [expr.reinterpret.cast 6]. Indeed, if
fn were overloaded, overload resolution fails to find any match.

--begin fptrconv.ii
void fn(int *);

void f()
{
  void (*fptr)(void *);
  
  fptr = fn;
}
--end fptrconv.ii

--begin transcript
nathan@manao:1491>uname -a                      
SunOS manao 5.6 Generic_105181-03 sun4u sparc SUNW,Ultra-5_10
nathan@manao:1492>ss-g++ -v -c fptrconv.ii -W -Wall 
Reading specs from /home/staff/nathan/solaris/local/sparc-SunOS_5/lib/gcc-lib/sparc-sun-solaris2.6/egcs-2.92.34/specs
gcc version egcs-2.92.34 19990103 (gcc2 ss-980609 experimental)
 /home/staff/nathan/solaris/local/sparc-SunOS_5/lib/gcc-lib/sparc-sun-solaris2.6/egcs-2.92.34/cc1plus fptrconv.ii -quiet -W -Wall -version -o /var/tmp/ccSaUJto.s
GNU C++ version egcs-2.92.34 19990103 (gcc2 ss-980609 experimental) (sparc-sun-solaris2.6) compiled by GNU C version egcs-2.91.57 19980901 (egcs-1.1 release).
 /usr/local/egcs/sparc-SunOS_5/bin/as -V -Qy -s -o fptrconv.o /var/tmp/ccSaUJto.s
GNU assembler version 970915 (sparc-sun-solaris2.5.1), using BFD version 970915
--end transcript

nathan
-- 
Dr Nathan Sidwell :: Computer Science Department :: Bristol University
      You can up the bandwidth, but you can't up the speed of light      
nathan@acm.org  http://www.cs.bris.ac.uk/~nathan/  nathan@cs.bris.ac.uk



More information about the Gcc-bugs mailing list