Skip to content
This repository was archived by the owner on Oct 12, 2022. It is now read-only.

add nothrow and @nogc to windows files#3796

Closed
WalterBright wants to merge 1 commit intodlang:masterfrom
WalterBright:nothrowNogc
Closed

add nothrow and @nogc to windows files#3796
WalterBright wants to merge 1 commit intodlang:masterfrom
WalterBright:nothrowNogc

Conversation

@WalterBright
Copy link
Copy Markdown
Member

blocking dlang/dmd#13960

@dlang-bot
Copy link
Copy Markdown
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.

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 + druntime#3796"

@dkorpel
Copy link
Copy Markdown
Contributor

dkorpel commented Apr 7, 2022

This turns callback types nothrow nogc as well, which is a breaking change. That might be fine, but worth considering.

@rainers
Copy link
Copy Markdown
Member

rainers commented Apr 7, 2022

This turns callback types nothrow nogc as well, which is a breaking change. That might be fine, but worth considering.

Yes, something to keep an eye on, but in this case the function types seem to be meant as types of the respected functions, e.g. to be used for casting the result of GetProcAddress("DllGetClassObject").

The change in unknwn.d doesn't change the interfaces (which would be too restrictive for implementing classes), so that won't help making vsoptions.d nothrow in dlang/dmd#13960.

@WalterBright
Copy link
Copy Markdown
Member Author

https://devblogs.microsoft.com/oldnewthing/20200911-00/?p=104205 suggests that COM interfaces are nothrow. They're also designed to be used with C, which doesn't throw.

@rainers
Copy link
Copy Markdown
Member

rainers commented Apr 7, 2022

Indeed, the STDMETHOD macro contains __declspec(nothrow) by default (can be disabled with a preprocessor define), but the IUnknown interface doesn't include it. Adding it is probably intended, but will break code now because overriding methods are unllikely to be annotated.

Not allowing arbitrary allocations with @nogc is more restrictive, though.

@WalterBright
Copy link
Copy Markdown
Member Author

@rainers what prompted this is I can't get dmd source code to be nothrow because some of it calls code in unknwn.d and vsoptions.d.

(Also, the AddRef and Release functions were designed before exception handling came about, and they obviously won't work with exceptions flying around.)

@rainers
Copy link
Copy Markdown
Member

rainers commented Apr 7, 2022

I understand what you are trying to do but

  • the change here isn't good enough, you will have to add nothrow @nogc: inside the interface declarations, too.
  • dmd is compiled with older versions, too, so it might take a while until the change is usable inside dmd

I forgot that attributes are inherited by overriding functions automatically, so that restricts breakage to implementations of these methods that call unannotated functions. I'm fine with updating my sources (though most use a different translation of the Windows headers anyway), but I suspect there will be some breakage.

@WalterBright
Copy link
Copy Markdown
Member Author

I rebooted this as #3797

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants