c++/8631: bug in typecasting the return value of a function

bangerth@dealii.org bangerth@dealii.org
Tue Nov 19 07:13:00 GMT 2002


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



More information about the Gcc-bugs mailing list