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

fix Issue 22894 - importC: static struct initializer can't take addre… #13881

Merged
merged 1 commit into from
Mar 24, 2022

Conversation

WalterBright
Copy link
Member

…ss of own field

@WalterBright WalterBright added the Feature:ImportC Pertaining to ImportC support label Mar 24, 2022
@dlang-bot
Copy link
Contributor

Thanks for your pull request, @WalterBright!

Bugzilla references

Auto-close Bugzilla Severity Description
22894 normal importC: static struct initializer can't take address of own field

Testing this PR locally

If you don't have a local development environment setup, you can use Digger to test this PR:

dub run digger -- build "master + dmd#13881"

Copy link
Contributor

@MoonlightSentinel MoonlightSentinel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CTFE still fails with this patch - the first expression in the initializer triggers Error: variable localS cannot be read at compile time):

int main()
{
    struct S localS =
    {
        &localS,
        0,
        &localS.first
    };

    assertImpl(localS.s == &localS);
    assertImpl(localS.first == 0);
    assertImpl(localS.last == &localS.first);
    return 0;
}

_Static_assert(main() == 0, "Test");

@WalterBright
Copy link
Member Author

@MoonlightSentinel that is a different problem with a different solution. Please file a separate bug report for that.

@WalterBright
Copy link
Member Author

@WalterBright WalterBright dismissed MoonlightSentinel’s stale review March 24, 2022 18:31

filed as a separate bug report

@WalterBright WalterBright merged commit 6799e31 into dlang:master Mar 24, 2022
@WalterBright WalterBright deleted the fix22894 branch March 24, 2022 18:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature:ImportC Pertaining to ImportC support Severity:Bug Fix
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants