This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/53637] NRVO not applied where there are two different variables involved


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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2015-02-04
            Summary|NRVO not applied in         |NRVO not applied where
                   |branches when it could be   |there are two different
                   |                            |variables involved
     Ever confirmed|0                           |1

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
The problem is that GCC does not do NRVO when there are two different variables
used.  If the variable was the same, GCC would do the correct thing.
That is:
Foo bar(int i) {
  Foo result;
  if (i > 1) {
    return result;
  } else {
    return result;
  }
}

NRVO is applied.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]