This is the mail archive of the gcc@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] |
On Sunday, October 10, 2004, at 07:48 AM, Richard Guenther wrote:
Is it legal for a conforming C++ compiler to optimize away storage allocation / deallocation? Like in
#include <new>
void foo(void) { int *x = new(std::nothrow) int; delete x; }
is it allowed to kill the new and delete statements? Would it be allowed to do this for the throwing version of new, too?
The as if rule is fairly powerful... If the resulting program behaves as if it had it, then the optimization is allowed. I don't think memory consumption is an externally visible effect. Now, we might need to do full program analysis to know which new is run, and to know its semantics; I don't recall if the user is prohibited from adding semantics to a new replacement function.
struct Vector { Vector(int size); Vector operator*(const Vector&); Vector& operator=(const Vector&); double *storage; };
Vector a,b,c; a = b*c;
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |