This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: c++/8631: bug in typecasting the return value of a function
- From: bangerth at dealii dot org
- To: gcc-bugs at gcc dot gnu dot org, gcc-prs at gcc dot gnu dot org, gkmohan at ece dot arizona dot edu, nobody at gcc dot gnu dot org
- Date: 19 Nov 2002 15:01:19 -0000
- Subject: Re: c++/8631: bug in typecasting the return value of a function
- Reply-to: bangerth at dealii dot org, gcc-bugs at gcc dot gnu dot org, gcc-prs at gcc dot gnu dot org, gkmohan at ece dot arizona dot edu, nobody at gcc dot gnu dot org, gcc-gnats at gcc dot gnu dot org
Synopsis: bug in typecasting the return value of a function
State-Changed-From-To: open->closed
State-Changed-By: bangerth
State-Changed-When: Tue Nov 19 07:01:18 2002
State-Changed-Why:
User error. You are trying nonsense and getting nonsense. No
surprise.
Had you used a static_cast instead of the C-style cast like
this:
f2( static_cast<CAST (*)(int)>(&f1), 4 );
then the compiler would tell you quite correctly:
tmp/g> /home/bangerth/bin/gcc-3.3x-pre/bin/c++ x.cc
x.cc: In function `int main()':
x.cc:18: error: invalid static_cast from type `int (*)(int)' to type `
std::complex<double> (*)(int)'
http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=8631