c++/4337: [2003-01-01]c++ ignores cast operator

giovannibajo@libero.it giovannibajo@libero.it
Mon May 5 01:32:00 GMT 2003


Synopsis: [2003-01-01]c++ ignores cast operator

State-Changed-From-To: analyzed->closed
State-Changed-By: bajo
State-Changed-When: Mon May  5 01:14:02 2003
State-Changed-Why:
    Not a bug. "a1 = (A1)a2" is a type conversion in cast 
    notation (§5.4). "a1 = const_cast<A1>(a2)" is 
    ill-formed, but "a1 = static_cast<A1>(a2)" is well-formed,
    because "a1 = A1(a2)" is well-formed (this is the exact
    condition specified by §5.2.9p2). Thus, for §5.4p5, the
    cast notation is equivalent to the static_cast notation.
    The static_cast notation is then equivalent to 
    "a1 = A1(a2)", which upcasts a2 to const A& implicitally,
    and then invokes A1(const A&). 
    G++ behaves exactly as the standard prescribes, and all
    the other compilers I have agree.
    If you need to force the use of the custom conversion 
    operator, you can still do it using the syntax
    "a1 = a2.operator A1()".

http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=4337



More information about the Gcc-bugs mailing list