From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 72168385840F for ; Tue, 25 Jul 2023 18:48:39 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 72168385840F Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1690310918; h=from:from:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:in-reply-to:in-reply-to: references:references; bh=o6Mu6CPABqa33XHYyvY90J2WnsXyXb45ePHxF0OdvHg=; b=FroF3dsdKdtLGeMz3Wr5JF3j6Wh3p4KZWn8Golt5NRo+ceWj2oLCaqeyqln+j1THprbsPV OO/LaEAI77GnazqBghaYpbkQc/VpK9MNrRHKlUruj4Q0C+rMVZWIXZbE9EI9GNrIimJgye vP4EPrw7RZs+viI1WN29/3p3VmLeF9c= Received: from mimecast-mx02.redhat.com (66.187.233.73 [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-396-JnsVeYvtPHyMydU3IotgeQ-1; Tue, 25 Jul 2023 14:48:37 -0400 X-MC-Unique: JnsVeYvtPHyMydU3IotgeQ-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id A52191C06ECE; Tue, 25 Jul 2023 18:48:36 +0000 (UTC) Received: from calimero.vinschen.de (unknown [10.39.193.241]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 6B20E40C2063; Tue, 25 Jul 2023 18:48:36 +0000 (UTC) Received: by calimero.vinschen.de (Postfix, from userid 500) id 4744BA80D29; Tue, 25 Jul 2023 20:48:35 +0200 (CEST) Date: Tue, 25 Jul 2023 20:48:35 +0200 From: Corinna Vinschen To: Sebastian Huber Cc: Bruno De Fraine , "newlib@sourceware.org" Subject: Re: newlib header breaks restricted pointers in C++ Message-ID: Reply-To: newlib@sourceware.org Mail-Followup-To: Sebastian Huber , Bruno De Fraine , "newlib@sourceware.org" References: <3126b987-ca19-97f6-9c7a-06243add9354@embedded-brains.de> MIME-Version: 1.0 In-Reply-To: <3126b987-ca19-97f6-9c7a-06243add9354@embedded-brains.de> X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Disposition: inline X-Spam-Status: No, score=-5.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,KAM_SHORT,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On Jul 25 19:46, Sebastian Huber wrote: > On 25.07.23 19:35, Corinna Vinschen wrote: > > Hi Bruno, > > > > On Jul 24 22:23, Bruno De Fraine wrote: > > > Hello, > > > > > > As an extension, GCC and clang offer C99-style restricted pointers in C++ mode: > > > https://gcc.gnu.org/onlinedocs/gcc/Restricted-Pointers.html > > > > > > We notice that this extension is broken when including newlib headers: restricted pointers are treated as ordinary pointers. > > > > > > We traced this to the following section of newlib/libc/include/sys/cdefs.h: > > > > > > /* > > > * GCC 2.95 provides `__restrict' as an extension to C90 to support the > > > * C99-specific `restrict' type qualifier. We happen to use `__restrict' as > > > * a way to define the `restrict' type qualifier without disturbing older > > > * software that is unaware of C99 keywords. > > > */ > > > #if !(__GNUC__ == 2 && __GNUC_MINOR__ == 95) > > > #if !defined(__STDC_VERSION__) || __STDC_VERSION__ < 199901 > > > #define __restrict > > > #else > > > #define __restrict restrict > > > #endif > > > #endif > > > > > > While the GCC __restrict extension was indeed introduced in GCC 2.95, it is not limited to this version; the extension is also not limited to C90: > > > https://gcc.gnu.org/gcc-2.95/c++features.html > > Either way, the above has been taken from FreeBSD, and it is still, > > as of today, the same expression as used in FreeBSDs sys/cdefs.h > > file. > > > > Seb, any input on this? > > I added a FreeBSD bug report: > > https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=272723 Great, thanks! Do we want to wait for a FreeBSD solution, or do we want to change it now and, maybe, take the FreeBSD version later? Does anybody want to provide a git compatible patch? Thanks, Corinna