gm2
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gm2] trouble deallocating


From: Derek Wyss
Subject: [Gm2] trouble deallocating
Date: Mon, 21 Mar 2016 18:51:55 -0500

Hello,

I'm having trouble deallocating.  The program posted below compiles, but when I run it I get the following message:

*** Error in `./a.out': free(): invalid size: 0x000000000060d3e0 ***
Aborted

If I comment out the deallocation line, it just prints out 'A' as I expect.  Am I doing something wrong or is the compiler misbehaving?

Best regards,

derek

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

MODULE SimplePointerProgram;

  FROM Storage IMPORT ALLOCATE, DEALLOCATE;
  FROM SYSTEM IMPORT ADR, ADDRESS;
  FROM StrIO IMPORT WriteLn, WriteString;
  FROM IO IMPORT Write;

  TYPE Node_Ref = POINTER TO Node;
  TYPE Node = RECORD
                char_in_node: CHAR;
              END;

  TYPE Char_Ptr = POINTER TO CHAR;

  VAR new_node: Node;
  VAR handle_for_node: Node_Ref;

  VAR ptr: Char_Ptr;
  VAR test_char: CHAR;

BEGIN
  test_char := 'A';

  ALLOCATE(ptr, SIZE(CHAR));
  ptr := ADR(test_char);

  Write(ptr^);
  WriteLn();

  DEALLOCATE(ptr, SIZE(CHAR));

END SimplePointerProgram.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

About my computer / environment:
Dell Latitude E5430
DISTRIB_ID=LinuxMint
DISTRIB_RELEASE=2
DISTRIB_CODENAME=betsy
DISTRIB_DESCRIPTION="LMDE 2 Betsy"
PRETTY_NAME="Linux Mint LMDE"
NAME="Linux Mint LMDE"
ID=linuxmint
ANSI_COLOR="1;31"
Architecture:          x86_64
CPU op-mode(s):        32-bit, 64-bit
Byte Order:            Little Endian
CPU(s):                4
On-line CPU(s) list:   0-3
Thread(s) per core:    2
Core(s) per socket:    2
Socket(s):             1
NUMA node(s):          1
Vendor ID:             GenuineIntel
CPU family:            6
Model:                 42
Model name:            Intel(R) Core(TM) i3-2328M CPU @ 2.20GHz

gm2 -v
Using built-in specs.
COLLECT_GCC=gm2
COLLECT_LTO_WRAPPER=/usr/lib/gm2/libexec/gcc//x86_64-linux-gnu/4.7.4/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../gm2/gcc-versionno/configure --enable-languages=c,c++,gm2 --prefix=/opt/gm2 --libexecdir=/usr/lib/gm2/libexec --infodir=/opt/gm2/share/info --mandir=/opt/gm2/share/man --enable-threads=posix --enable-clocale=gnu --disable-multilib --disable-bootstrap --enable-checking --enable-libgm2 --build=x86_64-linux-gnu --host=x86_64-linux-gnu
Thread model: posix
gcc version 4.7.4 (GCC)

reply via email to

[Prev in Thread] Current Thread [Next in Thread]