Xref: utzoo comp.lang.c++:6495 gnu.g++.bug:1487 Path: utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!brutus.cs.uiuc.edu!jarthur!uci-ics!rfg From: rfg@ics.uci.edu (Ronald Guilmette) Newsgroups: comp.lang.c++,gnu.g++.bug Subject: g++ 1.36.1 bug 900215_01 (really Re: Cast to void) Message-ID: <25DAF91A.29169@paris.ics.uci.edu> Date: 15 Feb 90 18:46:50 GMT References: <10742@june.cs.washington.edu> Reply-To: rfg@ics.uci.edu (Ronald Guilmette) Organization: UC Irvine Department of ICS Lines: 37 In article <10742@june.cs.washington.edu> david@june.cs.washington.edu (David Callahan) writes: >Is defining operator void legal? (g++ gave no messages) If so, it >seems that g++ is in error when the explicit cast is present. >Should implicit casts to void also invoke the operator void? I >certainly hope so since explicit casts to void seem very uncommon. // g++ 1.36.1 bug 900215_01 // g++ allows the definition of a type conversion operator `operator void' // for class types, but subsequently fails to generate calls (where needed) // for such type conversion operators. // Cfront 2.0 does generate such calls. // The following program exits with status 0 when compiled with Cfront 2.0 // but exits with status 1 when compiled with g++. struct struct0 { operator void (); }; int exit_status = 1; struct0::operator void () { exit_status = 0; } struct struct0 s0_object; int main () { (void) s0_object; return exit_status; }