Code Monkey home page Code Monkey logo

array's People

Contributors

shrddr avatar

Watchers

 avatar

array's Issues

Double deletion

MSVS2013 debug configuration:
The test program with this code hangs after reaching the end of scope:

Array a(2);
a.set(0, 42);
a.set(1, 69);
Array b(a);

MSVS2013 release configuration:
triggered a breakpoint at free.c

Ubuntu:
*** Error in `./test': double free or corruption (fasttop): 0x000000000188d010 ***

What happens:
Default copy constructor sets b.myData = a.myData.
Destructor of a deletes the myData array.
Then, destructor of b is called, tries to delete the same array and never succeeds.

Solution:
Create a custom copy constructor

G++ fail

g++ Array.cpp Test.cpp
In file included from Array.cpp:1:0:
Array.h:5:2: error: ‘size_t’ does not name a type

Debug Assertion Failed

Array a(2);
a.set(0, 42);
a.set(1, 69);
Array c(1);
c = a;

MSVS2013 debug:
Debug Assertion Failed!
File: f:\dd\vctools\crt_bld\self_x86\crt\src\dbgdel.cpp
Line: 52
Expression: _BLOCK_TYPE_IS_VALID(pHead->nBlockUse)

MSVS2013 release:
breakpoint at free.c

Ubuntu:
works fine

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.