Article View: gnu.g++.bug
Article #314Cast bug?
From: Tom Keffer
Date: Tue, 01 Aug 1989 14:34
Date: Tue, 01 Aug 1989 14:34
30 lines
1144 bytes
1144 bytes
It was my impression that under C++, the cast notations A(B) and (A)B
are equivalent when casting a B as an A. This is not always true
under g++ 1.35.0. Here is a code strip that illustrates the
difference:
class A {
};
class B {
public:
operator A();
};
void foo(A&);
main()
{
B b;
foo( A(b) ); // Error: type `A' does not have a constructor
foo( (A)b ); // OK
}
-tk
---
Dr. Thomas Keffer | Internet: keffer@sperm.ocean.washington.edu
School of Oceanography | BITNET: keffer%sperm.ocean.washington.edu@UWAVM
Univ. of Washington, WB-10 | uucp: uw-beaver!sperm.ocean.washington.edu!keffer
Seattle, WA 98195 | Telemail: T.KEFFER/OMNET
(206) 543-6455
Technical Details
Message-ID:
<8908011434.AA27017@sperm.ocean.washington.edu>Path:
arc1-ca.pugleaf.net!utzoo!telly!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!SPERM.OCEAN.WASHINGTON.EDU!kefferShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!telly!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!SPERM.OCEAN.WASHINGTON.EDU!keffer From: keffer@SPERM.OCEAN.WASHINGTON.EDU (Tom Keffer) Newsgroups: gnu.g++.bug Subject: Cast bug? Message-ID: <8908011434.AA27017@sperm.ocean.washington.edu> Date: 1 Aug 89 14:34:01 GMT Sender: daemon@tut.cis.ohio-state.edu Distribution: gnu Organization: GNUs Not Usenet Lines: 30