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++/19531] New: RVO is performed on volatile temporary


RVO is performed on a temporary object that is declared volatile.
That seems contradictory with the ISO standards 12.8 15 (object and copy must
have the same cv-unqualified type).

With the following piece of code, I was excepting the copy constructor and
destructor to be called.

struct String
{
  int field;

  String();
  String(int);
  ~String();
  String (const String &);
  String (volatile const String &);
};

String name()
{
  volatile String t(777);
  return t;
}

checking !TREE_VOLATILE (r) in finish_function where the named return value
optimization is set up fixes the problem.

-- 
           Summary: RVO is performed on volatile temporary
           Product: gcc
           Version: 3.4.3
            Status: UNCONFIRMED
          Severity: minor
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: christian dot bruel at st dot com
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: i686-pc-linux-gnu
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu


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


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