D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 23261 - druntime core.std.attribute.Tagged1_2 constructor is unsafe
Summary: druntime core.std.attribute.Tagged1_2 constructor is unsafe
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P3 normal
Assignee: No Owner
URL:
Keywords: pull
Depends on:
Blocks:
 
Reported: 2022-07-21 01:56 UTC by Walter Bright
Modified: 2023-01-06 07:43 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Walter Bright 2022-07-21 01:56:51 UTC
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.
Comment 1 Dlang Bot 2023-01-02 12:34:20 UTC
@RazvanN7 created dlang/dmd pull request #14771 "Fix Issue 23261 - druntime core.std.attribute.Tagged1_2 constructor i…" fixing this issue:

- Fix Issue 23261 - druntime core.std.attribute.Tagged1_2 constructor is unsafe

https://github.com/dlang/dmd/pull/14771
Comment 2 Mathias LANG 2023-01-05 10:35:32 UTC
Yes but the code is only intended to be used as an UDA, so it shouldn't matter.
Comment 3 Dlang Bot 2023-01-06 07:43:32 UTC
dlang/dmd pull request #14771 "Fix Issue 23261 - druntime core.std.attribute.Tagged1_2 constructor i…" was merged into master:

- bac6a64dfc90820809dff2c5609f03d1bdb532e9 by RazvanN7:
  Fix Issue 23261 - druntime core.std.attribute.Tagged1_2 constructor is unsafe

https://github.com/dlang/dmd/pull/14771