------- Additional Comments From bangerth at dealii dot org 2004-10-19 02:18 ------- You are storing pointers to temporaries. Look here: ----------------------------- template<typename T> class Constant { public: typedef T Type; private: const T* value_; public: Constant() : value_(0) {} explicit Constant(const T& value) : value_(&value) {} ... --------------------- Note how you store the address of the value given to the constructor. Then you use class Constant here: --------------------- template<typename L> inline FExpr< Mul<L, Constant<typename L::Type> > > operator*(const L& rleft, const typename L::Type& rright) { typedef typename L::Type Type; typedef Mul<L, Constant<Type> > expr_t; return FExpr<expr_t>(expr_t(rleft, Constant<Type>(rright))); } ----------------------------- so you pass the address of the second argument to this operator through to Constant. And you use this operator* in expressions like this: ----------------------------- X_*2.0 ----------------------------- in which you create a temporary of value 2 and pass it on to the result of the template expression. You later evaluate this expression template, but of course whatever is in the place where the 2.0 was stored is long gone and replaced by something different. The fact that it may have worked with optimization is just simple chance, or the compiler actually doing all the work of constant propagation for you. It is not a sign of a compiler bug, though. This PR is thus invalid. W.
-- What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |RESOLVED Resolution| |INVALID http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18049