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

Fixed issue with custom_struct global constructors #85

Merged
merged 1 commit into from
Nov 18, 2024

Conversation

AjayBrahmakshatriya
Copy link
Collaborator

There was a bug with BuildIt and unnamed custom structs with global variables.
Unnamed structs grab their names using the type_namer trait. This trait uses a static variable to keep track of types that already have a named assigned. However, we were using std::string to hold this name. It is possible that a global constructor could request a name but the static member hasn't been initialized yet. This reads an unconstructed std::string which invokes undefined behavior.
To fix this we make member to be a std::string* instead of std::string.

sample56 has been updated to test this.

@AjayBrahmakshatriya AjayBrahmakshatriya merged commit c980a84 into BuildIt-lang:master Nov 18, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant