[LLVMbugs] [Bug 17320] New: Can't assign PTHREAD_MUTEX_INITIALIZER to a class member
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Sat Sep 21 18:09:06 PDT 2013
http://llvm.org/bugs/show_bug.cgi?id=17320
Bug ID: 17320
Summary: Can't assign PTHREAD_MUTEX_INITIALIZER to a class
member
Product: clang
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Severity: normal
Priority: P
Component: C++
Assignee: unassignedclangbugs at nondot.org
Reporter: bero at lindev.ch
CC: dgregor at apple.com, llvmbugs at cs.uiuc.edu
Classification: Unclassified
Created attachment 11261
--> http://llvm.org/bugs/attachment.cgi?id=11261&action=edit
sample code showing failures and workaround
This code fails to compile, saying "expected expression" where it sees
PTHREAD_MUTEX_INITIALIZER:
#include <pthread.h>
class Test {
pthread_mutex_t m;
Test();
};
Test::Test():m(PTHREAD_MUTEX_INITIALIZER) {}
A variant of this, initializing through = assignment, fails as well, with the
same error:
#include <pthread.h>
class Test {
pthread_mutex_t m;
Test();
};
Test::Test() {
m = PTHREAD_MUTEX_INITIALIZER;
}
This is fine, though:
#include <pthread.h>
static const pthread_mutex_t __pthread_mutex_initializer =
PTHREAD_MUTEX_INITIALIZER;
class Test {
pthread_mutex_t m;
Test();
};
Test::Test():m(__pthread_mutex_initializer) {}
I've verified this on Linux with glibc (where PTHREAD_MUTEX_INITIALIZER is { {
0, 0, 0, 0, 0, __PTHREAD_SPINS, { 0, 0 } } } and Android (where
PTHREAD_MUTEX_INITIALIZER is { 0 }.
clang trunk svn rev. 190913.
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20130922/5edd6dc1/attachment.html>
More information about the llvm-bugs
mailing list