http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53288

Hubert Tong <hstong at ca dot ibm.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|rejects-valid               |wrong-code
            Version|4.6.0                       |4.7.0
            Summary|[C++11] Reference fails to  |[C++11] Lifetime of
                   |bind directly to prvalue    |temporary object backing
                   |member access expression    |pointer-to-member
                   |                            |expression not extended
      Known to fail|4.4.0, 4.5.0, 4.6.0         |4.7.0

--- Comment #2 from Hubert Tong <hstong at ca dot ibm.com> 2012-06-07 21:36:54 
UTC ---
(In reply to comment #1)
> It compiles fine with 4.7 or trunk.
> 
> I think this is a dup of an existing bug Jason fixed, possibly one he reported
> himself, about elements of rvalue arrays.

Confirmed that the above works as expected under 4.7.

However, replacing:
const B &b = A(1).b;

with:
const B &b = A(1).*(&A::b);

produces an executable whose output indicates that the lifetime of the
temporary is not being extended:

ctor B(int) body:       (this=0xffe9f7d8,_data=1)
ctor A(int) body:       (this=0xffe9f7d8,_data=1)
dtor for A:             (this=0xffe9f7d8,_data=1)
dtor for B:             (this=0xffe9f7d8,_data=1)
main() user body begins
main() user body ends

### g++ -v output:> g++-4.7.0 -v
Using built-in specs.
COLLECT_GCC=g++-4.7.0
COLLECT_LTO_WRAPPER=/data/gcc/libexec/gcc/powerpc64-unknown-linux-gnu/4.7.0/lto-wrapper
Target: powerpc64-unknown-linux-gnu
Configured with: ../gcc-4.7.0/configure --prefix=/data/gcc
--program-suffix=-4.7.0 --disable-libssp --disable-libgcj
--enable-version-specific-runtime-libs --with-cpu=default32 --enable-secureplt
--with-long-double-128 --enable-shared --enable-__cxa_atexit
--enable-threads=posix --enable-languages=c,c++,fortran --with-mpfr=/usr/local/
--with-mpc=/usr/local/ --with-gmp=/usr/local/
Thread model: posix
gcc version 4.7.0 (GCC)

Reply via email to