• <i id='MiFPh'><tr id='MiFPh'><dt id='MiFPh'><q id='MiFPh'><span id='MiFPh'><b id='MiFPh'><form id='MiFPh'><ins id='MiFPh'></ins><ul id='MiFPh'></ul><sub id='MiFPh'></sub></form><legend id='MiFPh'></legend><bdo id='MiFPh'><pre id='MiFPh'><center id='MiFPh'></center></pre></bdo></b><th id='MiFPh'></th></span></q></dt></tr></i><div id='MiFPh'><tfoot id='MiFPh'></tfoot><dl id='MiFPh'><fieldset id='MiFPh'></fieldset></dl></div>
    <legend id='MiFPh'><style id='MiFPh'><dir id='MiFPh'><q id='MiFPh'></q></dir></style></legend>

        <bdo id='MiFPh'></bdo><ul id='MiFPh'></ul>

    1. <tfoot id='MiFPh'></tfoot>
      1. <small id='MiFPh'></small><noframes id='MiFPh'>

      2. 没有 delete() 的 new() 是未定义行为还是仅仅是内存泄漏?

        new() without delete() is Undefined Behavior or merely Memory Leak?(没有 delete() 的 new() 是未定义行为还是仅仅是内存泄漏?)

        <legend id='yJ9K0'><style id='yJ9K0'><dir id='yJ9K0'><q id='yJ9K0'></q></dir></style></legend>

        <tfoot id='yJ9K0'></tfoot>
        • <bdo id='yJ9K0'></bdo><ul id='yJ9K0'></ul>
          <i id='yJ9K0'><tr id='yJ9K0'><dt id='yJ9K0'><q id='yJ9K0'><span id='yJ9K0'><b id='yJ9K0'><form id='yJ9K0'><ins id='yJ9K0'></ins><ul id='yJ9K0'></ul><sub id='yJ9K0'></sub></form><legend id='yJ9K0'></legend><bdo id='yJ9K0'><pre id='yJ9K0'><center id='yJ9K0'></center></pre></bdo></b><th id='yJ9K0'></th></span></q></dt></tr></i><div id='yJ9K0'><tfoot id='yJ9K0'></tfoot><dl id='yJ9K0'><fieldset id='yJ9K0'></fieldset></dl></div>
              <tbody id='yJ9K0'></tbody>

              <small id='yJ9K0'></small><noframes id='yJ9K0'>

                  本文介绍了没有 delete() 的 new() 是未定义行为还是仅仅是内存泄漏?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  可能的重复:
                  内存泄漏是未定义行为"吗?C++中的类问题?

                  永远不要对 newnew [] 返回的地址调用 deletedelete[]C++ 程序是未定义行为还是仅仅是内存泄漏?

                  Never calling delete or delete[] on address returned by new or new [] resp in a C++ program is an Undefined Behavior or merely a memory leak?

                  欢迎参考标准(如果有).
                  这出现在这里的评论之一中.我只是对此有点困惑.

                  References from the Standard(if any) are welcome.
                  This came up in one of the comments here & I am just a bit confused about it.

                  推荐答案

                  [basic.life](3.8 对象生命周期)第4段讲:

                  [basic.life] (3.8 Object lifetime) in paragraph 4 tells :

                  程序可以通过重用对象占用的存储或通过显式调用具有非平凡析构函数的类类型对象的析构函数来结束任何对象的生命周期.对于具有非平凡析构函数的类类型的对象,在该对象占用的存储空间被重用或释放之前,程序不需要显式调用析构函数;但是,如果没有显式调用析构函数或者如果没有使用删除表达式(5.3.5)来释放存储,则不应隐式调用析构函数,并且任何依赖于副作用的程序都不会产生由析构函数未定义行为.

                  A program may end the lifetime of any object by reusing the storage which the object occupies or by explicitly calling the destructor for an object of a class type with a non-trivial destructor. For an object of a class type with a non-trivial destructor, the program is not required to call the destructor explicitly before the storage which the object occupies is reused or released; however, if there is no explicit call to the destructor or if a delete-expression (5.3.5) is not used to release the storage, the destructor shall not be implicitly called and any program that depends on the side eects produced by the destructor has undened behavior.

                  这篇关于没有 delete() 的 new() 是未定义行为还是仅仅是内存泄漏?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Constructor initialization Vs assignment(构造函数初始化 Vs 赋值)
                  Is a `=default` move constructor equivalent to a member-wise move constructor?(`=default` 移动构造函数是否等同于成员移动构造函数?)
                  Has the new C++11 member initialization feature at declaration made initialization lists obsolete?(声明时新的 C++11 成员初始化功能是否使初始化列表过时了?)
                  Order of constructor call in virtual inheritance(虚继承中构造函数调用的顺序)
                  How to use sfinae for selecting constructors?(如何使用 sfinae 选择构造函数?)
                  Initializing a union with a non-trivial constructor(使用非平凡的构造函数初始化联合)
                  1. <tfoot id='gzqU2'></tfoot>

                      <bdo id='gzqU2'></bdo><ul id='gzqU2'></ul>
                        <tbody id='gzqU2'></tbody>

                      <small id='gzqU2'></small><noframes id='gzqU2'>

                      <legend id='gzqU2'><style id='gzqU2'><dir id='gzqU2'><q id='gzqU2'></q></dir></style></legend>

                        <i id='gzqU2'><tr id='gzqU2'><dt id='gzqU2'><q id='gzqU2'><span id='gzqU2'><b id='gzqU2'><form id='gzqU2'><ins id='gzqU2'></ins><ul id='gzqU2'></ul><sub id='gzqU2'></sub></form><legend id='gzqU2'></legend><bdo id='gzqU2'><pre id='gzqU2'><center id='gzqU2'></center></pre></bdo></b><th id='gzqU2'></th></span></q></dt></tr></i><div id='gzqU2'><tfoot id='gzqU2'></tfoot><dl id='gzqU2'><fieldset id='gzqU2'></fieldset></dl></div>