[Issue 24735] Enum is not work within the member function in the synchronized class

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sat Aug 31 11:55:40 UTC 2024


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

--- Comment #2 from Haruki Shigemori <rayerd.wiz at gmail.com> ---
enum
{
        ENUM1 = 1
}

enum ENUM2 = 2;

synchronized class A
{
        void f()
        {
                auto a = ENUM1; // NG, but ENUM1 is constant.
                auto b = ENUM2; // OK
        }
}

void main()
{
        auto a = new shared(A);
        a.f();
}

source\text.d(12,12): Error: direct access to shared `ENUM1` is not allowed,
see `core.atomic`

Why is ENUM1 shared and ENUM2 not shared?

--


More information about the Digitalmars-d-bugs mailing list