Changeset dc86541


Ignore:
Timestamp:
Nov 9, 2016, 1:53:40 PM (5 years ago)
Author:
Rob Schluntz <rschlunt@…>
Branches:
aaron-thesis, arm-eh, cleanup-dtors, deferred_resn, demangler, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, resolv-new, with_gc
Children:
8780e30
Parents:
a29be37
Message:

do not destruct lvalue returns

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/InitTweak/FixInit.cc

    ra29be37 rdc86541  
    1818#include <iterator>
    1919#include <algorithm>
     20#include <unordered_map>
     21#include <unordered_set>
    2022#include "InitTweak.h"
    2123#include "FixInit.h"
     
    445447                                impCpCtorExpr->get_returnDecls().push_back( ret );
    446448                                CP_CTOR_PRINT( std::cerr << "makeCtorDtor for a return" << std::endl; )
    447                                 destructRet( new VariableExpr( ret ) , impCpCtorExpr );
     449                                if ( ! result->get_isLvalue() ) {
     450                                        // destructing lvalue returns is bad because it can cause multiple destructor calls to the same object - the returned object is not a temporary
     451                                        destructRet( new VariableExpr( ret ), impCpCtorExpr );
     452                                }
    448453                        } // for
    449454                        CP_CTOR_PRINT( std::cerr << "after Resolving: " << impCpCtorExpr << std::endl; )
Note: See TracChangeset for help on using the changeset viewer.