c++ - Does this cause undefined behavior? -


address sanitizer complaining.

struct x {   iterator begin();   iterator end(); };  x foo();  const x& bar(const x& x) {   return x; }  boost_foreach(const auto& xitem, bar(foo())) {   //use xitem } 

yes. foreach happening on reference struct has been created foo call, , gone out of scope after being passed through bar()


Comments

Popular posts from this blog

java - Oracle EBS .ClassNotFoundException: oracle.apps.fnd.formsClient.FormsLauncher.class ERROR -

c# - how to use buttonedit in devexpress gridcontrol -

nvd3.js - angularjs-nvd3-directives setting color in legend as well as in chart elements -