Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6195957
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T03:33:37+00:00 2026-05-24T03:33:37+00:00

Here’s a minimal code that puzzles me : #include <list> class A; class A

  • 0

Here’s a minimal code that puzzles me :

#include <list>

class A;

class A {
private:
    std::list<A*> a_list;
//  int a_list;
public:
    A() : a_list() {}
};

int main() {
    A* a_tab = new A[1];
//  A* a_tab = new A();

    delete a_tab;

    return 0;
}

At execution, I got :

*** glibc detected *** ./main: free(): invalid pointer: 0x0000000000f6d018 ***
======= Backtrace: =========
/lib/libc.so.6(+0x774b6)[0x7f706f2914b6]
/lib/libc.so.6(cfree+0x73)[0x7f706f297c83]
./main[0x4007d2]
/lib/libc.so.6(__libc_start_main+0xfe)[0x7f706f238d8e]
./main[0x400649]
======= Memory map: ========
00400000-00402000 r-xp 00000000 08:03 108600                             /DELL/Users/Lucas/Desktop/Lifebeam/minimal/main
00601000-00602000 r--p 00001000 08:03 108600                             /DELL/Users/Lucas/Desktop/Lifebeam/minimal/main
00602000-00603000 rw-p 00002000 08:03 108600                             /DELL/Users/Lucas/Desktop/Lifebeam/minimal/main
00f6d000-00f8e000 rw-p 00000000 00:00 0                                  [heap]
7f7068000000-7f7068021000 rw-p 00000000 00:00 0 
7f7068021000-7f706c000000 ---p 00000000 00:00 0 
7f706f21a000-7f706f394000 r-xp 00000000 08:07 400996                     /lib/libc-2.12.1.so
7f706f394000-7f706f593000 ---p 0017a000 08:07 400996                     /lib/libc-2.12.1.so
7f706f593000-7f706f597000 r--p 00179000 08:07 400996                     /lib/libc-2.12.1.so
7f706f597000-7f706f598000 rw-p 0017d000 08:07 400996                     /lib/libc-2.12.1.so
7f706f598000-7f706f59d000 rw-p 00000000 00:00 0 
7f706f59d000-7f706f5b2000 r-xp 00000000 08:07 391760                     /lib/libgcc_s.so.1
7f706f5b2000-7f706f7b1000 ---p 00015000 08:07 391760                     /lib/libgcc_s.so.1
7f706f7b1000-7f706f7b2000 r--p 00014000 08:07 391760                     /lib/libgcc_s.so.1
7f706f7b2000-7f706f7b3000 rw-p 00015000 08:07 391760                     /lib/libgcc_s.so.1
7f706f7b3000-7f706f835000 r-xp 00000000 08:07 401151                     /lib/libm-2.12.1.so
7f706f835000-7f706fa34000 ---p 00082000 08:07 401151                     /lib/libm-2.12.1.so
7f706fa34000-7f706fa35000 r--p 00081000 08:07 401151                     /lib/libm-2.12.1.so
7f706fa35000-7f706fa36000 rw-p 00082000 08:07 401151                     /lib/libm-2.12.1.so
7f706fa36000-7f706fb1e000 r-xp 00000000 08:07 1048147                    /usr/lib/libstdc++.so.6.0.14
7f706fb1e000-7f706fd1d000 ---p 000e8000 08:07 1048147                    /usr/lib/libstdc++.so.6.0.14
7f706fd1d000-7f706fd25000 r--p 000e7000 08:07 1048147                    /usr/lib/libstdc++.so.6.0.14
7f706fd25000-7f706fd27000 rw-p 000ef000 08:07 1048147                    /usr/lib/libstdc++.so.6.0.14
7f706fd27000-7f706fd3c000 rw-p 00000000 00:00 0 
7f706fd3c000-7f706fd5c000 r-xp 00000000 08:07 401152                     /lib/ld-2.12.1.so
7f706ff3b000-7f706ff40000 rw-p 00000000 00:00 0 
7f706ff5a000-7f706ff5c000 rw-p 00000000 00:00 0 
7f706ff5c000-7f706ff5d000 r--p 00020000 08:07 401152                     /lib/ld-2.12.1.so
7f706ff5d000-7f706ff5e000 rw-p 00021000 08:07 401152                     /lib/ld-2.12.1.so
7f706ff5e000-7f706ff5f000 rw-p 00000000 00:00 0 
7fffdf34a000-7fffdf36b000 rw-p 00000000 00:00 0                          [stack]
7fffdf3da000-7fffdf3db000 r-xp 00000000 00:00 0                          [vdso]
ffffffffff600000-ffffffffff601000 r-xp 00000000 00:00 0                  [vsyscall]
Abandon

There are two commented lines : they are both (independently) an alternative that work fine to the line that precede them.

Do you have any clue why it behaves this way ?

I compile with g++ (Ubuntu/Linaro 4.4.4-14ubuntu5) 4.4.5.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T03:33:37+00:00Added an answer on May 24, 2026 at 3:33 am

    You use wrong deletion. You have allocated an array of one element using operator new[], but you delete as a single object using operator delete. Use delete[] a_tab; instead.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

here's the code: #include <string> class Config { public: static const std::string asdf =
Here is my object constructor static class Edge { int source; // source node
here a a piece of code that is supposed to loop over and over
Here is my simplified data structure: Object1.h template <class T> class Object1 { private:
Here's my test function (c#, visual studio 2010): [TestMethod()] public void TestGetRelevantWeeks() { List<sbyte>
Here is a snippet of my JavaScript Code that I want to DRY up:
Here's what I'm doing: List<Category> categories = db.Categories.Include(SubCategories).OrderBy(c => c.Order).ToList(); I have a column
Here's a part of a code that should do something and then call the
Here's a basic regex technique that I've never managed to remember. Let's say I'm
Here is the issue I am having: I have a large query that needs

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.