[LLVMbugs] [Bug 17320] Can't assign PTHREAD_MUTEX_INITIALIZER to a class member

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Sat Sep 21 22:45:12 PDT 2013


http://llvm.org/bugs/show_bug.cgi?id=17320

David Majnemer <david.majnemer at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |david.majnemer at gmail.com
         Resolution|---                         |INVALID

--- Comment #1 from David Majnemer <david.majnemer at gmail.com> ---
PTHREAD_MUTEX_INITIALIZER is a macro that expands to { { 0, 0, 0, 0, 0, 0, { 0,
0 } } }

Your test case is actually taking advantage of a C++11 feature, extended
initializer lists. See:
http://en.wikipedia.org/wiki/C%2B%2B11#Initializer_lists

gcc (as of 4.8), as an extension, allows it in c++98 mode with a warning:
"warning: extended initializer lists only available with -std=c++11 or
-std=gnu++11 [enabled by default]"

icc acts in a similar manner.

Compiling your test case with -std=c++11 yields a perfectly cromulent AST:
  |-CXXCtorInitializer Field 0x6a8c330 'm' 'pthread_mutex_t':'pthread_mutex_t'
  | |-CXXConstructExpr 0x6a8e038 <col:16, col:43>
'pthread_mutex_t':'pthread_mutex_t' 'void (pthread_mutex_t &&) noexcept'
elidable
  | | `-MaterializeTemporaryExpr 0x6a8df40 </usr/include/pthread.h:90:3,
col:36> 'pthread_mutex_t' xvalue 
  | |   `-InitListExpr 0x6a8ddb8 <col:3, col:36> 'pthread_mutex_t' 
  | |     `-InitListExpr 0x6a8de00 <col:5, col:34> 'struct
__pthread_mutex_s':'struct pthread_mutex_t::__pthread_mutex_s' 
  | |       |-IntegerLiteral 0x6a8d880 <col:7> 'int' 0 
  | |       |-ImplicitCastExpr 0x6a8de78 <col:10> 'unsigned int' <IntegralCast> 
  | |       | `-IntegerLiteral 0x6a8d8a0 <col:10> 'int' 0 
  | |       |-IntegerLiteral 0x6a8d8c0 <col:13> 'int' 0 
  | |       |-ImplicitCastExpr 0x6a8de90 <col:16> 'unsigned int' <IntegralCast> 
  | |       | `-IntegerLiteral 0x6a8d8e0 <col:16> 'int' 0 
  | |       |-IntegerLiteral 0x6a8d900 <col:19> 'int' 0 
  | |       |-IntegerLiteral 0x6a8d920 <col:22> 'int' 0 
  | |       `-InitListExpr 0x6a8dea8 <col:25, col:32>
'__pthread_list_t':'struct __pthread_internal_list' 
  | |         |-ImplicitCastExpr 0x6a8def8 <col:27> 'struct
__pthread_internal_list *' <NullToPointer> 
  | |         | `-IntegerLiteral 0x6a8d940 <col:27> 'int' 0 
  | |         `-ImplicitCastExpr 0x6a8df10 <col:30> 'struct
__pthread_internal_list *' <NullToPointer> 
  | |           `-IntegerLiteral 0x6a8d960 <col:30> 'int' 0 
  `-CompoundStmt 0x6a8e0a0 </var/tmp/PR17320.cpp:7:45, col:46>

Marking this as invalid.

-- 
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/693db260/attachment.html>


More information about the llvm-bugs mailing list