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

core.stdc.stdio.snprintf returns wrong value if the buffer is not sufficiently large #98

Open
mdparker opened this issue Jun 21, 2023 · 0 comments

Comments

@mdparker
Copy link
Member

ogion.art reported this on 2021-09-02T12:09:26Z

Transfered from https://issues.dlang.org/show_bug.cgi?id=22266

Description

According to C99 specification, if the buffer is not sufficiently large, snprintf should still return the number of characters that would have been written. However, the implementation that DMD uses by default on Windows returns -1 instead.

void main() {
    import core.stdc.stdio;
    auto n = snprintf(null, 0, "test");
    assert(n == 4); //fails 
}

Comments

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant