[Issue 13589] [git-head] Asm statement could be assumed to nothrow, safe, pure by the enclosing function attribute

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Wed Oct 8 09:31:01 PDT 2014


https://issues.dlang.org/show_bug.cgi?id=13589

--- Comment #7 from yebblies <yebblies at gmail.com> ---
(In reply to Kenji Hara from comment #6)
> 
> void f3() @safe pure {
>   asm {...}
>   // f3 has explicit @safe attribute, so asm is inferred as @trusted, pure,
> but throwable
> }
> 

This is a problem.  f3 is _not_ @safe, it is @trusted.  But unlike other
violations, you won't find it by grepping for @trusted.

> It could be more serious. If someone want to write a kernel code with D,
> mixing inline assembler and regular D code may be painful. It would be a
> serious flaw against the goal "D is a system language".

I don't think it is a serious flaw against that goal.  Everything is still
possible, and not very difficult either.  I would much rather have the
attributes be opt-in than opt-out at the statement level, where the compiler
can't decide automatically.

> 
> It is case by case. *In phobos*, it is less than 100 asm, but we would
> already have large code base we are unknown. I believe D will be a
> widespread language, so we should imagine the quite big use cases even they
> are not visible.

This isn't an argument that these uses exist and are widespread, and therefore
worth catering too.  The proposed change is also backwards-compatible.

--


More information about the Digitalmars-d-bugs mailing list