[gnu.g++.bug] g++ 1.36.1 bug 900215_01

rfg@ics.uci.edu (Ronald Guilmette) (02/16/90)

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;
}