digitalmars.D.learn - Local variable disappears.
**Hi there, my Dear Fellows.** i been encountering w/ strange issue.. [ret_emp __emp (..)](https://github.com/SarK0Y/DLang/blob/b8e8bb39dda4b5180218998f4700940e218b46f4/source/emp.d#L108) ... [line 126](https://github.com/SarK0Y/DLang/blob/b8e8bb39dda4b5180218998f4700940e218b46f4/source/emp.d#L126) ```D /**********/ map.name = "name1"; //runs fine *map = 0; map.prnt; simply_print_time ("start tst for __emp"); map.prnt; // SIGSEGV /*************/ ``` Any ideas??? **|||||||||||||||Thanks a lot in Advance.** ==================
Dec 22 2025
On Monday, 22 December 2025 at 13:53:54 UTC, SarK0Y wrote:**Hi there, my Dear Fellows.** i been encountering w/ strange issue.. [ret_emp __emp (..)](https://github.com/SarK0Y/DLang/blob/b8e8bb39dda4b5180218998f4700940e218b46f4/source/emp.d#L108) ... [line 126](https://github.com/SarK0Y/DLang/blob/b8e8bb39dda4b5180218998f4700940e218b46f4/source/emp.d#L126) ```D /**********/ map.name = "name1"; //runs fine *map = 0; map.prnt; simply_print_time ("start tst for __emp"); map.prnt; // SIGSEGV /*************/ ``` Any ideas??? **|||||||||||||||Thanks a lot in Advance.** ==================You have this wonderful line nuking your memory: ``` *map = 0; ```
Dec 22 2025
On Monday, 22 December 2025 at 16:54:56 UTC, bauss wrote:On Monday, 22 December 2025 at 13:53:54 UTC, SarK0Y wrote: You have this wonderful line nuking your memory: ``` *map = 0; ```Thanks for Your reply, but i disagree.. ```D map.name = "name1"; *map = 0; // if it torpedoes memory map.prnt; // then sigsegv must be here simply_print_time ("start tst for __emp"); map.prnt; // but it's here ```
Dec 22 2025
On Monday, 22 December 2025 at 17:03:48 UTC, SarK0Y wrote:On Monday, 22 December 2025 at 16:54:56 UTC, bauss wrote:It is undefined behavior, so it can happen at anytime, anywhere.On Monday, 22 December 2025 at 13:53:54 UTC, SarK0Y wrote: You have this wonderful line nuking your memory: ``` *map = 0; ```Thanks for Your reply, but i disagree.. ```D map.name = "name1"; *map = 0; // if it torpedoes memory map.prnt; // then sigsegv must be here simply_print_time ("start tst for __emp"); map.prnt; // but it's here ```
Dec 22 2025
*On Monday, 22 December 2025 at 17:05:16 UTC, bauss wrote: On Monday, 22 December 2025 at 17:05:16 UTC, bauss wrote:On Monday, 22 December 2025 at 17:03:48 UTC, SarK0Y wrote:**Nice shot == Thanks for Your Help :))**On Monday, 22 December 2025 at 16:54:56 UTC, bauss wrote:It is undefined behavior, so it can happen at anytime, anywhere.On Monday, 22 December 2025 at 13:53:54 UTC, SarK0Y wrote: You have this wonderful line nuking your memory: ``` *map = 0; ```Thanks for Your reply, but i disagree.. ```D map.name = "name1"; *map = 0; // if it torpedoes memory map.prnt; // then sigsegv must be here simply_print_time ("start tst for __emp"); map.prnt; // but it's here ```
Dec 22 2025
On Monday, 22 December 2025 at 17:05:16 UTC, bauss wrote:On Monday, 22 December 2025 at 17:03:48 UTC, SarK0Y wrote:unfortunately, situation been not that simple == seems there is problem to initialize class GmpInt properly: i made two funcs to create class.. [zz.mk](https://github.com/SarK0Y/DLang/blob/556fefa36e51b46a80de3717d8c495842c36224f/source/class_gmp_z.d#L141) ```D static zz* mk () { auto __zz = new zz(0); auto size_zz = __traits (classInstanceSize, GmpInt); auto alloc_zz = cast (zz) malloc (size_zz); alloc_zz = __zz.dup; alloc_zz.name = "alloc_zz"; alloc_zz.prnt; zz* ret = &alloc_zz; ret.prnt; return ret; } ``` [zz._mk](https://github.com/SarK0Y/DLang/blob/556fefa36e51b46a80de3717d8c495842c36224f/source/class_gmp_z.d#L152) ```D static zz* _mk() { auto __zz = new zz(0); zz* ret = &__zz; return ret; } ``` in short, not sufficient allocation is very culprit here.. PS. variant w/ malloc runs more stable :)On Monday, 22 December 2025 at 16:54:56 UTC, bauss wrote:It is undefined behavior, so it can happen at anytime, anywhere.On Monday, 22 December 2025 at 13:53:54 UTC, SarK0Y wrote: You have this wonderful line nuking your memory: ``` *map = 0; ```Thanks for Your reply, but i disagree.. ```D map.name = "name1"; *map = 0; // if it torpedoes memory map.prnt; // then sigsegv must be here simply_print_time ("start tst for __emp"); map.prnt; // but it's here ```
Dec 22 2025









SarK0Y <sark0y protonmail.com> 