From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4842 invoked by alias); 23 Aug 2008 18:48:02 -0000 Received: (qmail 4808 invoked by uid 22791); 23 Aug 2008 18:48:01 -0000 X-Spam-Check-By: sourceware.org Received: from aaronwl.com (HELO aaronwl.com) (68.228.0.128) by sourceware.org (qpsmtpd/0.31) with ESMTP; Sat, 23 Aug 2008 18:47:26 +0000 Received: from [172.16.42.2] (stormy.internal.aaronwl.com [172.16.42.2]) by aaronwl.com (8.12.11/8.12.11) with ESMTP id m7NIlLp0007940; Sat, 23 Aug 2008 13:47:21 -0500 Message-ID: <48B05B22.8010001@aaronwl.com> Date: Sat, 23 Aug 2008 19:42:00 -0000 From: "Aaron W. LaFramboise" User-Agent: Thunderbird 2.0.0.16 (Windows/20080708) MIME-Version: 1.0 To: Richard Guenther CC: gcc-patches@gcc.gnu.org Subject: Re: [PATCH] Make the pointer parameter to __gthread_setspecific non-const References: <48768624.4090608@aaronwl.com> <48B0456D.7090602@aaronwl.com> <84fc9c000808231026y50f9201g85f5aa45d230bf29@mail.gmail.com> In-Reply-To: <84fc9c000808231026y50f9201g85f5aa45d230bf29@mail.gmail.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org X-SW-Source: 2008-08/txt/msg01758.txt.bz2 Richard Guenther wrote: > On Sat, Aug 23, 2008 at 7:14 PM, Aaron W. LaFramboise > wrote: >> Currently on i386-pc-mingw32, casting away constness in >> __gthread_setspecific causes a bootstrap failure with --enable-werror. This >> must be true for a number of other targets which do the same thing. >> >> The ultimate problem here is that there's nothing about this parameter that >> is const: __gthread_getspecific returns a non-const pointer, not a const >> one. > But pthread_setspecific _does_ take a constant pointer as argument. Oh, how unfortunate. I think this is a defect in POSIX pthreads. This means if you pass in a const void * to pthread_setspecific, you can get a void * back out of pthread_getspecific, losing the constness without ever casting. > Why not add an explicit cast for the mingw32 case? An explicit cast does not kill the warning. The union trick is the only way to get rid of it, and the encapsulation for this trick, CONST_CAST, is not available to gthr.h. *-mingw* is not the only target with this issue. Pretty much all non-pthreads targets have to cast away constness in the same way, since most other threading APIs apparently get this right. So, is it better here to deviate slightly from pthreads, to do what seems more correct, or to use the union trick to make this warning go away in all pthreads targets? I'm happy either way; someone just let me know what I should do.