www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 18277] New: synchronized statement with comma operator


          Issue ID: 18277
           Summary: synchronized statement with comma operator ignores
                    first arguments
           Product: D
           Version: D2
          Hardware: x86
                OS: Windows
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: simen.kjaras gmail.com

According to TDPL[1], synchronized (a, b) should should lock both a and b. This
does not happen:

import std.stdio;
import core.thread;

class C {}

class MyThread1 : Thread {
    C c, d;
    this(C c, C d) {
        this.c = c;
        this.d = d;
    void run() {
        synchronized(c, d) {
            writeln("Thread sleeping...");
            writeln("Thread woke up");

unittest {
    C c = new C;
    C d = new C;
    auto derived = new MyThread1(c, d).start();
    synchronized(c) {
        writeln("c is not synchronized");
    synchronized(d) {
        writeln("d is synchronized");

Expected output:
Thread sleeping...
Thread woke up
c is not synchronized
d is synchronized

Actual output:
Thread sleeping...
c is not synchronized
Thread woke up
d is synchronized

[1]: http://www.informit.com/articles/article.aspx?p=1609144&seqNum=15

Jan 22 2018