You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When compiling with the paramter --app:staticLib --noMain:off, the compiler doesn't insert calls to =destroy for objects both ref objects and objects at the end of main.
type
TObj = object
text: string
val: int
proc `=destroy`*(x: var TObj ) =
echo("TObj destroyed, x.text ", x.text)
when isMainModule:
var obj = (ref TObj )(text: "tt1", val: 1)
var obj2 = TObj (text: "tt2", val: 2)
echo(obj.text)
echo(obj2.text)
# Neither obj or obj2 are destroyed at the end of main when target is staticLib
This can be observed by inspecting the compiled C source in the function
When compiling to an executable, then the compiler inserts the destructors but not for static library.
Nim Version
Nim Compiler Version 1.7.3 [Windows: amd64]
Compiled at 2022-11-27
Copyright (c) 2006-2022 by Andreas Rumpf
git hash: 5a848a0
active boot switches: -d:release
Current Output
No response
Expected Output
No response
Possible Solution
No response
Additional Information
No response
The text was updated successfully, but these errors were encountered:
IgorDeepakM
changed the title
Nim doesn't insert call to =destroy when compiled to staticLib
Compiler doesn't insert call to =destroy when compiled to staticLib
Nov 27, 2022
Description
When compiling with the paramter --app:staticLib --noMain:off, the compiler doesn't insert calls to
=destroy
for objects both ref objects and objects at the end of main.This can be observed by inspecting the compiled C source in the function
N_LIB_PRIVATE N_NIMCALL(void, NimMainModule)(void)
When compiling to an executable, then the compiler inserts the destructors but not for static library.
Nim Version
Nim Compiler Version 1.7.3 [Windows: amd64]
Compiled at 2022-11-27
Copyright (c) 2006-2022 by Andreas Rumpf
git hash: 5a848a0
active boot switches: -d:release
Current Output
No response
Expected Output
No response
Possible Solution
No response
Additional Information
No response
The text was updated successfully, but these errors were encountered: