[Issue 23261] New: druntime core.std.attribute.Tagged1_2 constructor is unsafe

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Jul 21 01:56:51 UTC 2022


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

          Issue ID: 23261
           Summary: druntime core.std.attribute.Tagged1_2 constructor is
                    unsafe
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: bugzilla at digitalmars.com

The code is:

version (UdaGNUAbiTag) struct gnuAbiTag
{
    string[] tags;

    this(string[] tags...)
    {
        this.tags = tags;
    }
}

Note that tags[] is constructed on the stack, so this is creating an expired
pointer on the stack, which can result in memory corruption. If the code is
marked with @safe, it will not compile.

--


More information about the Digitalmars-d-bugs mailing list