[gnu.g++.bug] reference to rvalue

vaughan%cadillac.cad.mcc.com@MCC.COM (Paul Vaughan) (12/15/89)

	The following source produces incorrect output when compiled
with g++-1.36.1 and the latest version of 1.36.2 on a SUN3

struct A {
  A(int j) : i(j) {}
  int i;
};

A& a = A(1);

main() {
  if(a.i != 1) a.i = 1/0;
}
[2.155]puma) g++-1.36.1 -v -g -O -DX11  -o fref fref.cc -lg++ -llwp -lX11 -lm 
gcc version 1.36.1 (based on GCC 1.36)
 /usr/local/gnu/1.36/lib/gcc-cpp -+ -v -DX11 -undef -D__GNUC__ -D__GNUG__ -D__cplusplus -Dmc68000 -Dsun -Dunix -D__mc68000__ -D__sun__ -D__unix__ -D__OPTIMIZE__ -D__HAVE_68881__ -Dmc68020 fref.cc /usr/tmp/cca23598.cpp
GNU CPP version 1.36
 /usr/local/gnu/1.36/lib/gcc-cc1plus /usr/tmp/cca23598.cpp -quiet -dumpbase fref.cc -g -O -version -o /usr/tmp/cca23598.s
GNU C++ version 1.36.1 (based on GCC 1.36) (68k, MIT syntax) compiled by GNU C version 1.36.
default target switches: -m68020 -mc68020 -m68881 -mbitfield
 /usr/local/gnu/1.36/lib/gcc-as -mc68020 -o fref.o /usr/tmp/cca23598.s
 /usr/local/gnu/1.36/lib/gcc-ld -o fref -e start -dc -dp -Bstatic /lib/crt0.o /lib/Mcrt1.o fref.o -lg++ -llwp -lX11 -lm -lg++ /usr/local/gnu/1.36/lib/gcc-gnulib -lg -lc
[2.156]puma) fref
Arithmetic exception
------------------------------------------
It should not produce the Arithmetic exception.  It looks like the
scope of the temporary generated (see Lippman, page 36) to implement
the reference to an rvalue is not correct.  I've printed the value a.i
(instead of doing the if(a.i != 1) a.i = 1/0;, and the result I got
was 4.  I expect your mileage will vary.