[Issue 12980] Undefined behavior: Assignment of static string to dynamic string

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Tue Jun 24 04:25:41 PDT 2014


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

Jonathan M Davis <jmdavisProg at gmx.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |jmdavisProg at gmx.com
         Resolution|---                         |INVALID

--- Comment #2 from Jonathan M Davis <jmdavisProg at gmx.com> ---
This code is perfectly legal. It just isn't safe. And if @safe were properly
implemented with regards to slicing static arrays, and you marked your code
here with @safe, then the compiler would generate an error when the static
array was sliced. Unfortunately however, slicing static arrays is currently a
hole in @safe:

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

But regardless, there's no bug in the language in your example, just in your
code. It's not marked with @safe, so it's @system, so even if bug# 8838 were
fixed, your code would still compile, because @system code is not checked for
memory safety, and it's perfectly possible to do unsafe things with memory in
@system code.

--


More information about the Digitalmars-d-bugs mailing list