Thread overview
[Issue 11471] [profile+nothrow] `asm` statements rejected in `nothrow` functions if built with "-profile"
Jun 08, 2014
yebblies
Jun 08, 2014
Orvid King
Jun 20, 2014
Kenji Hara
Jun 29, 2014
Kenji Hara
Jun 29, 2014
Kenji Hara
Jun 29, 2014
Kenji Hara
Jun 29, 2014
Kenji Hara
June 08, 2014
https://issues.dlang.org/show_bug.cgi?id=11471

yebblies <yebblies@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |yebblies@gmail.com

--- Comment #4 from yebblies <yebblies@gmail.com> ---
This really should be generating the same error with and without profile.  I have no idea why it doesn't.  For some reason the function's type is not marked as nothrow until _after_ the first time blockExit is run on it.

--
June 08, 2014
https://issues.dlang.org/show_bug.cgi?id=11471

--- Comment #5 from Orvid King <blah38621@gmail.com> ---
I would agree that assuming asm statements always throw is not exactly useful, especially as the inline asm statements are there for performance. Is there some way that either the compiler could check to see if the asm actually throws, or else for the user to tell the compiler that an ASM statement doesn't throw?

--
June 20, 2014
https://issues.dlang.org/show_bug.cgi?id=11471

--- Comment #6 from Kenji Hara <k.hara.pg@gmail.com> ---
The root issue is in FuncDeclaration::semantic3.

    ...
    else if (hasReturnExp & 8)               // if inline asm
    {
        flags &= ~FUNCFLAGnothrowInprocess;
    }
    else
    {
        // Check for errors related to 'nothrow'.
        unsigned int nothrowErrors = global.errors;
        int blockexit = fbody->blockExit(this, f->isnothrow);
        if (f->isnothrow && (global.errors != nothrowErrors) )
            ::error(loc, "%s '%s' is nothrow yet may throw", kind(),
toPrettyChars());
    ...

In front-end, if a function body has inline asm statements, the function's nothrow check is skipped! But many functions in druntime rely on the loose behavior currently.

--
June 29, 2014
https://issues.dlang.org/show_bug.cgi?id=11471

Kenji Hara <k.hara.pg@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Depends on|                            |12979

--
June 29, 2014
https://issues.dlang.org/show_bug.cgi?id=11471

Kenji Hara <k.hara.pg@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Depends on|                            |12979

--
June 29, 2014
https://issues.dlang.org/show_bug.cgi?id=11471

Kenji Hara <k.hara.pg@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull
         Depends on|12979                       |

--- Comment #7 from Kenji Hara <k.hara.pg@gmail.com> ---
Workaround fix: https://github.com/D-Programming-Language/dmd/commit/e6c308938d02d1cbfc57c37c03d06bff0ec00c74


Test case addition: https://github.com/D-Programming-Language/dmd/pull/3702

--
June 29, 2014
https://issues.dlang.org/show_bug.cgi?id=11471

--- Comment #8 from github-bugzilla@puremagic.com ---
Commits pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/31b5a22bfb5415ecd953e90fad967a537c27bd53
fix Issue 11471 - [profile+nothrow] `asm` statements rejected in `nothrow`
functions if built with "-profile"

Workaround fix is introduced in e6c308938d02d1cbfc57c37c03d06bff0ec00c74, so just add a test case.

https://github.com/D-Programming-Language/dmd/commit/968566c3620707480a77c38a17d5d8317a0ff4f7 Merge pull request #3702 from 9rnsr/fix11471

[REG2.066a] Issue 11471 - [profile+nothrow] `asm` statements rejected in `nothrow` functions if built with "-profile"

--
June 29, 2014
https://issues.dlang.org/show_bug.cgi?id=11471

github-bugzilla@puremagic.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |FIXED

--
June 29, 2014
https://issues.dlang.org/show_bug.cgi?id=11471

Kenji Hara <k.hara.pg@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|FIXED                       |WORKSFORME

--
October 06, 2014
https://issues.dlang.org/show_bug.cgi?id=11471
Issue 11471 depends on issue 12979, which changed state.

Issue 12979 Summary: Nothrow violation error is hidden by inline assembler https://issues.dlang.org/show_bug.cgi?id=12979

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |FIXED

--