public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/53288] New: [C++11] Reference fails to bind directly to prvalue member access expression
@ 2012-05-09  4:44 hstong at ca dot ibm.com
  2012-05-09 17:31 ` [Bug c++/53288] " redi at gcc dot gnu.org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: hstong at ca dot ibm.com @ 2012-05-09  4:44 UTC (permalink / raw)
  To: gcc-bugs

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

             Bug #: 53288
           Summary: [C++11] Reference fails to bind directly to prvalue
                    member access expression
    Classification: Unclassified
           Product: gcc
           Version: 4.6.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: hstong@ca.ibm.com
              Host: powerpc64-unknown-linux-gnu
            Target: powerpc64-unknown-linux-gnu


In the reference initialization,
   const B &b = A(1).b;
the initializer expression is a class prvalue.

The requirement to bind an lvalue reference to a non-volatile const type
directly to a reference-compatible class prvalue dates back to DR 391 which
PR 25950 intended to implement.

The error messages complaining about the private and deleted move constructor
indicate that direct binding was not done.


### Self-contained source (tempbind_expr_ref.cpp):> cat tempbind_expr_ref.cpp
extern "C" int printf(const char *, ...);

struct B {
   B(int data) : _data(data) {
printf("ctor B(int) body:       (this=%p,_data=%d)\n", (void *)this, _data);
   }
   ~B() {
printf("dtor for B:             (this=%p,_data=%d)\n", (void *)this, _data);
   }

   int _data;

private:
   B() = delete;
   B(const B &) = delete;
   B(B &&) = delete;
};

struct A {
   B b;
   A(int data) : b(data) {
printf("ctor A(int) body:       (this=%p,_data=%d)\n", (void *)this, b._data);
   }
   ~A() {
printf("dtor for A:             (this=%p,_data=%d)\n", (void *)this, b._data);
   }

private:
   A() = delete;
   A(const A &) = delete;
   A(A &&) = delete;
};

const B &b = A(1).b;

int main() {
    printf("main() user body begins\n");
    printf("main() user body ends\n");
}


### Compiler invocation:
g++-4.6.0 tempbind_expr_ref.cpp -std=c++0x


### Compiler output:
tempbind_expr_ref.cpp:16:4: error: 'B::B(B&&)' is private
tempbind_expr_ref.cpp:34:19: error: within this context
tempbind_expr_ref.cpp:34:19: error: use of deleted function 'B::B(B&&)'
tempbind_expr_ref.cpp:16:4: error: declared here


### g++ -v output:> g++-4.6.0 -v
Using built-in specs.
COLLECT_GCC=g++-4.6.0
COLLECT_LTO_WRAPPER=/data/gcc/libexec/gcc/powerpc64-unknown-linux-gnu/4.6.0/lto-wrapper
Target: powerpc64-unknown-linux-gnu
Configured with: ./configure --prefix=/data/gcc --program-suffix=-4.6.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-gmp=/usr/local
Thread model: posix
gcc version 4.6.0 (GCC)


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2023-08-11 20:36 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-05-09  4:44 [Bug c++/53288] New: [C++11] Reference fails to bind directly to prvalue member access expression hstong at ca dot ibm.com
2012-05-09 17:31 ` [Bug c++/53288] " redi at gcc dot gnu.org
2012-06-07 21:37 ` [Bug c++/53288] [C++11] Lifetime of temporary object backing pointer-to-member expression not extended hstong at ca dot ibm.com
2022-06-09 18:00 ` iamsupermouse at mail dot ru
2022-12-19 22:33 ` jason at gcc dot gnu.org
2023-01-23  0:36 ` cvs-commit at gcc dot gnu.org
2023-08-11 20:36 ` jason at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).