Article View: gnu.g++.bug
Article #2091reference to rvalue
From: Paul Vaughan
Date: Thu, 14 Dec 1989 23:41
Date: Thu, 14 Dec 1989 23:41
31 lines
1948 bytes
1948 bytes
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.
Technical Details
Message-ID:
<8912142341.AA23622@puma.cad.mcc.com>Path:
arc1-ca.pugleaf.net!utzoo!telly!attcan!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!tut.cis.ohio-state.edu!MCC.COM!vaughan%cadillac.cad.mcc.comShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!telly!attcan!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!tut.cis.ohio-state.edu!MCC.COM!vaughan%cadillac.cad.mcc.com From: vaughan%cadillac.cad.mcc.com@MCC.COM (Paul Vaughan) Newsgroups: gnu.g++.bug Subject: reference to rvalue Message-ID: <8912142341.AA23622@puma.cad.mcc.com> Date: 14 Dec 89 23:41:11 GMT Sender: daemon@tut.cis.ohio-state.edu Distribution: gnu Organization: GNUs Not Usenet Lines: 31