Remove error for asm statements in a nothrow function#4030
Remove error for asm statements in a nothrow function#4030ibuclaw wants to merge 1 commit intodlang:masterfrom
Conversation
|
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. |
|
The /real/ dodgyness is this: https://issues.dlang.org/show_bug.cgi?id=12979 |
If we can't verify it doesn't throw, how can we allow it in nothrow functions?
Yes. |
|
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 ( |
|
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: |
|
I'm going to close this as merely removing the error message doesn't fix the underlying issue - asm code can throw. |
|
I've posted a fix for Issue 12979 that implements
BTW, please use permalinks when referencing line numbers. You can do so by pressing y on the file view (more). |
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