# Strange behavior in module \_\_init\_\_

**URL:** https://discourse.julialang.org/t/strange-behavior-in-module-init/23887
**Category:** General Usage
**Created:** [May 5, 2019, 10:35pm UTC](https://discourse.julialang.org/t/strange-behavior-in-module-init/23887 "2019-05-05T22:35:28Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Alexander\_Belopolsky](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/alexander_belopolsky/32/4882_2.png) [@Alexander\_Belopolsky](https://discourse.julialang.org/u/Alexander_Belopolsky)
#### Post date: [May 5, 2019, 10:35pm UTC](https://discourse.julialang.org/t/strange-behavior-in-module-init/23887/1 "2019-05-05T22:35:28Z")

</div>

I created a simple module with just the following code:

```julia
$ cat X/src/X.jl
module X

function __init__ ()
    @show Ptr{UInt8}(0x123456789abcdef0)
end

end # module

```

When I run it directly from the command line, I get expected result:

```nohighlight
$ julia X/src/X.jl
Ptr{UInt8}(0x123456789abcdef0) = Ptr{UInt8} @0x123456789abcdef0

```

but when I load it with “using”, I get all zeros

```nohighlight
$ julia -e 'using X'
Ptr{UInt8}(0x123456789abcdef0) = Ptr{UInt8} @0x0000000000000000

```

What is happening here?

---

<div class="post-metadata">

### Author: ![tkoolen](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tkoolen/32/1603_2.png) [@tkoolen](https://discourse.julialang.org/u/tkoolen)
#### Post date: [May 6, 2019, 3:51am UTC](https://discourse.julialang.org/t/strange-behavior-in-module-init/23887/2 "2019-05-06T03:51:59Z")

</div>

The closest thing I could find in the documentation is in [Modules · The Julia Language](https://docs.julialang.org/en/v1/manual/modules/#Module-initialization-and-precompilation-1),

> Constants involving most Julia objects that are not produced by `ccall` do not need to be placed in ` __init__ ` : their definitions can be precompiled and loaded from the cached module image. This includes complicated heap-allocated objects like arrays. However, any routine that returns a raw pointer value must be called at runtime for precompilation to work ( **Ptr objects will turn into null pointers unless they are hidden inside an isbits object** ). This includes the return values of the Julia functions `cfunction` and `pointer` .

So I _think_ that means that when a module is precompiled, any constant pointer (like the literal value in your ` __init__ `) is turned into null in the cached module image.
