Closed Bug 824390 Opened 7 years ago Closed 7 years ago

DMD failing to build with clang 3.2

Categories

(Core :: DMD, defect)

x86_64
Linux
defect
Not set

Tracking

()

RESOLVED FIXED
mozilla20

People

(Reporter: njn, Assigned: njn)

Details

Attachments

(1 file)

I just updated my Linux box to Ubuntu 12.10, which uses clang 3.2.  I'm getting this compile failure:

 1:50.80 /home/njn/moz/mi2/memory/replace/dmd/DMD.cpp:321:14: error: expected expression
 1:50.80     : mMutex(PTHREAD_MUTEX_INITIALIZER)
 1:50.80              ^
 1:50.80 /usr/include/pthread.h:90:3: note: expanded from macro 'PTHREAD_MUTEX_INITIALIZER'
 1:50.80   { { 0, 0, 0, 0, 0, 0, { 0, 0 } } }
 1:50.80   ^
 1:50.83 1 error generated.
 1:50.83 

It compiles with GCC 4.7.  The problem is demonstrated more clearly by this test program:

  struct X {
    int x1;
  };

  class Y {
    X x;
    Y() : x({0}) {}
  };

g++ says:

 a.cpp: In constructor ‘Y::Y()’:
 a.cpp:7:12: warning: extended initializer lists only available with -std=c++11 or -std=gnu++11 [enabled by default]
 a.cpp:7:16: warning: extended initializer lists only available with -std=c++11 or -std=gnu++11 [enabled by default]

but clang++ just says:

 a.cpp:7:13: error: expected expression
     Y() : x({0}) {}

But |clang++ -std=c++11| accepts it.

Hmm.
Simple fix.
Attachment #695369 - Flags: review?(justin.lebar+bug)
Attachment #695369 - Flags: review?(justin.lebar+bug) → review+
Hm.  Actually, do we know that pthread_mutex_init doesn't allocate?
> Hm.  Actually, do we know that pthread_mutex_init doesn't allocate?

PTHREAD_MUTEX_INITIALIZER clearly doesn't, so I'm willing to assume that pthread_mutex_init doesn't.
Living dangerously, sgtm.  :)
https://hg.mozilla.org/mozilla-central/rev/4aeb3016da03
Status: ASSIGNED → RESOLVED
Closed: 7 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla20
Component: General → DMD
You need to log in before you can comment on or make changes to this bug.