Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple initializations of a constant when using pointerof() #13054

Open
max-codeware opened this issue Feb 9, 2023 · 1 comment
Open

Multiple initializations of a constant when using pointerof() #13054

max-codeware opened this issue Feb 9, 2023 · 1 comment
Labels
kind:bug A bug in the code. Does not apply to documentation, specs, etc. topic:compiler:semantic

Comments

@max-codeware
Copy link
Contributor

Considering the following code:

Foo = begin
  puts "Initializing Foo"
end
 
pointerof(Foo)

The outputs is:

Initializing Foo
Initializing Foo

Apparently, when the pointer of a constant is taken, the once_init guard loses track of the initialization status causing multiple initializations.
You can see more in this discussion

@max-codeware max-codeware added the kind:bug A bug in the code. Does not apply to documentation, specs, etc. label Feb 9, 2023
@crysbot
Copy link
Collaborator

crysbot commented May 29, 2024

This issue has been mentioned on Crystal Forum. There might be relevant details there:

https://forum.crystal-lang.org/t/is-there-any-optimization-for-constants/5341/21

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind:bug A bug in the code. Does not apply to documentation, specs, etc. topic:compiler:semantic
Projects
None yet
Development

No branches or pull requests

3 participants