summaryrefslogtreecommitdiffstats
path: root/examples/cpu-hello-world/main.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'examples/cpu-hello-world/main.cpp')
-rw-r--r--examples/cpu-hello-world/main.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/examples/cpu-hello-world/main.cpp b/examples/cpu-hello-world/main.cpp
index 4ece04da2..6e06f64bc 100644
--- a/examples/cpu-hello-world/main.cpp
+++ b/examples/cpu-hello-world/main.cpp
@@ -49,7 +49,10 @@ static SlangResult _innerMain(int argc, char** argv)
// somewhat heavy-weight operation. When possible, an application
// should try to re-use the same session across multiple compiles.
//
- ComPtr<slang::IGlobalSession> slangSession(spCreateSession(NULL));
+ // NOTE that we use attach instead of setting via assignment, as assignment will increase
+ // the refcount. spCreateSession returns a IGlobalSession with a refcount of 1.
+ ComPtr<slang::IGlobalSession> slangSession;
+ slangSession.attach(spCreateSession(NULL));
// As touched on earlier, in order to generate the final executable code,
// the slang code is converted into C++, and that C++ needs a 'prelude' which