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

Remove error for asm statements in a nothrow function #4030

Closed
wants to merge 1 commit into from

Conversation

ibuclaw
Copy link
Member

@ibuclaw ibuclaw commented Sep 26, 2014

From discussion:
http://forum.dlang.org/post/m02c7p$226e$1@digitalmars.com

And this check is already impossible to hit because of:
https://github.com/D-Programming-Language/dmd/blob/master/src/func.c#L1778

There's already a test for this in: test/compilable/test11471.d - kinda, but druntime already depends on asm statements not causing this error in nothrow functions.

https://github.com/D-Programming-Language/druntime/blob/dbf3ff2a98208b21ee2d820df2c526af75ace863/src/core/thread.d#L2230

@yebblies
Copy link
Member

Can't we add a way to mark asm blocks as nothrow or something? Having them automatically ignored seems kind of dodgy.

@ibuclaw
Copy link
Member Author

ibuclaw commented Sep 26, 2014

Can't we add a way to mark asm blocks as nothrow or something? Having them automatically ignored seems kind of dodgy.

The question isn't ignoring them. It's about whether or not saying that asm throws is a valid statement in the first place.

@ibuclaw
Copy link
Member Author

ibuclaw commented Sep 26, 2014

The /real/ dodgyness is this: https://issues.dlang.org/show_bug.cgi?id=12979

@yebblies
Copy link
Member

The question isn't ignoring them. It's about whether or not saying that asm throws is a valid statement in the first place.

If we can't verify it doesn't throw, how can we allow it in nothrow functions?

The /real/ dodgyness is this: https://issues.dlang.org/show_bug.cgi?id=12979

Yes.

@WalterBright
Copy link
Member

Asm code can call other functions, which may throw.

@ibuclaw
Copy link
Member Author

ibuclaw commented Sep 27, 2014

Asm code can call other functions, which may throw

I would have thought that you'd be able to work out if this could potentially happen, such as when you've taken the address of a function in an asm statement (asmSemantic ?) and the function is not marked as nothrow.

@WalterBright
Copy link
Member

This kinda depends on how far you want the compiler go to analyze the asm instructions and figure out what it is doing. I find this to be fraught with hazards, as part of the point of clever asm code is to be clever.

Perhaps a better solution is to annotate the asm statement, as in:

asm nothrow { ... }

@WalterBright
Copy link
Member

I'm going to close this as merely removing the error message doesn't fix the underlying issue - asm code can throw.

@ibuclaw ibuclaw deleted the asmnothrow branch September 28, 2014 11:47
@MartinNowak MartinNowak modified the milestone: ddmd Sep 29, 2014
@MartinNowak
Copy link
Member

I've posted a fix for Issue 12979 that implements asm nothrow {} (#4033).

https://github.com/D-Programming-Language/dmd/blob/master/src/func.c#L1778

BTW, please use permalinks when referencing line numbers. You can do so by pressing y on the file view (more).

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