[Bug c++/59186] decltype(this) treated specially in trailing-return-specifier

2013-11-19 Thread osensei80 at gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59186

Marcel Wid  changed:

   What|Removed |Added

 CC||osensei80 at gmail dot com

--- Comment #2 from Marcel Wid  ---
§5.1.1/3 [expr.prim.general] states:

"If a declaration declares a member function or member function template of a
class X, the expression this is a prvalue of type “pointer to cv-qualifier-seq
X” between the optional cv-qualifer-seq and the end of the function-definition,
member-declarator, or declarator. It shall not appear before the optional
cv-qualifier-seq and it shall not appear within the declaration of a static
member function (although its type and value category are defined within a
static member function as they are within a non-static member function)."

Hence, I think gcc 4.9 is correct: 

struct s {
  auto f() -> decltype(this) { return this; } // `this` refers to `struct s`
  void g() {
struct t {
  decltype(this) g() { return static_cast(nullptr); } // same as above
  auto h() -> decltype(this) { return static_cast(nullptr); } // here
`this` refers to the inner struct `t` and there is no conversion from `s*` to
`s::g()::t*`.
};
  }
};

[Bug c++/67302] New: copy elision in return (expression)

2015-08-21 Thread osensei80 at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67302

Bug ID: 67302
   Summary: copy elision in return (expression)
   Product: gcc
   Version: 5.1.0
Status: UNCONFIRMED
  Severity: minor
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: osensei80 at gmail dot com
  Target Milestone: ---

Consider:

struct A
{
  A() { std::cout << "default ctor\n"; }
  A(const A&) { std::cout << "copy ctor\n"; }
  A(A&&) { std::cout << "move ctor\n"; }
};

A bar()
{
  A a;
  return( a );
}

int main()
{
  bar();
}

Compiling with option -std=c++11 the output is "default ctor". But compiling
with -std=c++14 or -std=c++1z the output is

default ctor
move ctor

Why get's the move not elided?