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

move assert() code past end of function #7386

Merged
merged 1 commit into from
Dec 6, 2017

Conversation

WalterBright
Copy link
Member

@dlang-bot
Copy link
Contributor

Thanks for your pull request, @WalterBright!

Bugzilla references

Your PR doesn't reference any Bugzilla issue.

If your PR contains non-trivial changes, please reference a Bugzilla issue or create a manual changelog.

@WalterBright
Copy link
Member Author

For code:

void test(int i) {
    assert(i, "message");
}

the following is now generated:

_D4test4testFiZv:
                sub     ESP,01Ch
                mov     018h[ESP],EAX
                cmp     dword ptr 018h[ESP],0
                je      L12
                add     ESP,01Ch
                ret
L12:            mov     ECX,offset FLAT:___a6_746573742e64
                mov     EAX,6
                mov     EDX,offset FLAT:___a7_6d657373616765
                mov     dword ptr 010h[ESP],5
                mov     EBX,7
                mov     0Ch[ESP],ECX
                mov     8[ESP],EAX
                mov     4[ESP],EDX
                mov     [ESP],EBX
                call    near ptr __d_assert_msg

@thewilsonator
Copy link
Contributor

I can't comment on the code, but I will note that this doesn't apply only to asserts, but to all slow path noreturn branches e.g. conditional branches that terminate in a throw or calls to functions that are noreturn (e.g. enforce) and asserts.

@WalterBright
Copy link
Member Author

I know, but one thing at a time!

@thewilsonator
Copy link
Contributor

Fair enough.

@WalterBright WalterBright force-pushed the assert-exit branch 3 times, most recently from fec67ad to 06dd7f5 Compare December 4, 2017 08:51
@ibuclaw
Copy link
Member

ibuclaw commented Jan 4, 2019

This caused a regression: https://issues.dlang.org/show_bug.cgi?id=19550

@thewilsonator
Copy link
Contributor

I haven't done much much complexity analysis, but that looks O(pretty bad) to me.

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.

5 participants