DMARC-Filter: OpenDMARC Filter v1.4.2 delorie.com 55ENg6872631457 Authentication-Results: delorie.com; dmarc=pass (p=none dis=none) header.from=cygwin.com Authentication-Results: delorie.com; spf=pass smtp.mailfrom=cygwin.com DKIM-Filter: OpenDKIM Filter v2.11.0 delorie.com 55ENg6872631457 Authentication-Results: delorie.com; dkim=pass (1024-bit key, unprotected) header.d=cygwin.com header.i=@cygwin.com header.a=rsa-sha256 header.s=default header.b=StB2bb3z X-Recipient: archive-cygwin AT delorie DOT com DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 23C0B3995171 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cygwin.com; s=default; t=1749944525; bh=SkGFu9FCjEi0HwKk9r603OgWUuPEtTpnBTthrrlHuBM=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=StB2bb3zcZcBsejmZ1zNPGiTpJBYsLDNXRN7Pzh3vgTrbhp9asfV6EQKDxdCf8Y9P Wk9Q8EoRqdjp71jVCN4HpljBQsHHMfpGBKhbaqlXmaFp+tYatsl5kvGGPR9UWwqFcq /BPjEeQV+++KNFy3CCvthkzihD9lAYV2+fyt/OqY= X-Original-To: cygwin AT cygwin DOT com Delivered-To: cygwin AT cygwin DOT com DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org BCB30384E6B9 ARC-Filter: OpenARC Filter v1.0.0 sourceware.org BCB30384E6B9 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1749944498; cv=none; b=RP5WwgatkGwgnn6jQi5vjhFmKdJfetdDyICnN7Opqxrvv0FYwiGzT5DHhpyvrqeVG+L9j8Ol4byLQ1354HconorWM4NeRGen0T2AhWxUjvTGpPmKbeB5gzFmmNzyZ3ZoLnJ+iGTm/84MQGHrFgH9CidDBBHhtQg9n9Zl24Z/KfE= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1749944498; c=relaxed/simple; bh=KIx82kMeD1mTf0YOLgTgJtDy/OS51tHMxTE+Qljzn4w=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=H5FrHrZYnC+AAZ4jVo6JaUUXNIFV1T/UI+GiN8mEpW6qTBmCFa1Hs0Kc7AXUmNqZOpWbmoJCO86DD2qfsIqFp++W5QDwxD1BkPYIjp9IUCGafddQyzIFMaR/oUh8JgE1at+9vBEhrDkjbVf5aWwZq3NPbX17PLEtmMnAb6Pht8I= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org BCB30384E6B9 Date: Sat, 14 Jun 2025 16:41:38 -0700 (PDT) X-X-Sender: jeremyd AT resin DOT csoft DOT net To: cygwin AT cygwin DOT com Subject: PTHREAD_MUTEX_INITIALIZER and constinit Message-ID: <87a87123-9ecb-ac15-ddb4-4cdfdf9faee4@jdrake.com> MIME-Version: 1.0 X-BeenThere: cygwin AT cygwin DOT com X-Mailman-Version: 2.1.30 List-Id: General Cygwin discussions and problem reports List-Archive: List-Post: List-Help: List-Subscribe: , From: Jeremy Drake via Cygwin Reply-To: Jeremy Drake Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "Cygwin" Consider the following -std=c++20: #include constinit pthread_mutex_t foo = PTHREAD_MUTEX_INITIALIZER; With g++ 12.4.0, this succeeds, but with clang 20.1.6 it fails: pthreadtest.cpp:3:27: error: variable does not have a constant initializer 3 | constinit pthread_mutex_t foo = PTHREAD_MUTEX_INITIALIZER; | ^ ~~~~~~~~~~~~~~~~~~~~~~~~~ pthreadtest.cpp:3:1: note: required by 'constinit' specifier here 3 | constinit pthread_mutex_t foo = PTHREAD_MUTEX_INITIALIZER; | ^~~~~~~~~ pthreadtest.cpp:3:33: note: cast that performs the conversions of a reinterpret_cast is not allowed in a constant expression 3 | constinit pthread_mutex_t foo = PTHREAD_MUTEX_INITIALIZER; | ^ /usr/include/pthread.h:49:35: note: expanded from macro 'PTHREAD_MUTEX_INITIALIZER' 49 | #define PTHREAD_MUTEX_INITIALIZER PTHREAD_NORMAL_MUTEX_INITIALIZER_NP | ^ /usr/include/pthread.h:47:45: note: expanded from macro 'PTHREAD_NORMAL_MUTEX_INITIALIZER_NP' 47 | #define PTHREAD_NORMAL_MUTEX_INITIALIZER_NP (pthread_mutex_t)19 | ^ 1 error generated. It seems the standard disallows this sort of cast pretty comprehensively. Is there some way that Cygwin's pthread initializer macros can be made compatible with constinit? -- Problem reports: https://cygwin.com/problems.html FAQ: https://cygwin.com/faq/ Documentation: https://cygwin.com/docs.html Unsubscribe info: https://cygwin.com/ml/#unsubscribe-simple