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

Section and type conversion inside a function blows up section size #101

Open
mandar1jn opened this issue May 13, 2024 · 0 comments
Open

Comments

@mandar1jn
Copy link
Contributor

Given the following pattern:

import std.mem;

#pragma array_limit -1

union StringToByteConverter<auto size>
{
    u8 data[size];
    str val;
};

fn main()
{
    u128 size = 2;

    auto fileSection = std::mem::create_section("file");

    StringToByteConverter<size> converter @ 0x0 in fileSection;

    converter.val = "a" * size;
};

it would be expected for the "file" section to have a size of 0x2. Instead it has a size of 0x40000002.

Moving the code to global scope (so outside of main) resolves this issue.

Issue verified by AxCut on Discord.

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

No branches or pull requests

1 participant