https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82899

Martin Sebor <msebor at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |msebor at gcc dot gnu.org
           See Also|                            |https://gcc.gnu.org/bugzill
                   |                            |a/show_bug.cgi?id=81009

--- Comment #7 from Martin Sebor <msebor at gcc dot gnu.org> ---
See also bug 81009 for a related optimization opportunity (this one having to
do with const objects/members).

A ctor declaration cannot be qualified but G++ does seem top allow the
__restrict qualifier on a ctor definition outside the class with the expected
effect.

Explicitly annotating the argument of the copy ctor with __restrict keyword is
valid and has the expected effect:

$ cat t.C && gcc -O2 -S -fdump-tree-optimized=/dev/stdout t.C
struct test {
    char data[2] = {1, 2};

    test(const test& v);
    ~test(){} // non trivial destructor!
};

test::test(const test& __restrict v) /* __restrict here works too */
    : data{ v.data[0], v.data[0] }
{}

;; Function test::test (_ZN4testC2ERKS_, funcdef_no=4, decl_uid=2331,
cgraph_uid=4, symbol_order=4)

test::test (struct test * const restrict this, const struct test & v)
{
  char _1;

  <bb 2> [local count: 10000]:
  _1 = *v_5(D).data[0];
  *this_3(D).data[0] = _1;
  *this_3(D).data[1] = _1;
  return;

}

Reply via email to