From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 20960 invoked by alias); 20 Sep 2013 14:59:31 -0000 Mailing-List: contact gcc-help-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-help-owner@gcc.gnu.org Received: (qmail 20950 invoked by uid 89); 20 Sep 2013 14:59:31 -0000 Received: from mail-ob0-f170.google.com (HELO mail-ob0-f170.google.com) (209.85.214.170) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Fri, 20 Sep 2013 14:59:31 +0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.3 required=5.0 tests=AWL,BAYES_00,KHOP_THREADED,NO_RELAYS autolearn=ham version=3.3.2 X-HELO: mail-ob0-f170.google.com Received: by mail-ob0-f170.google.com with SMTP id va2so696412obc.29 for ; Fri, 20 Sep 2013 07:59:28 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type; bh=aXXHijm7Ev+nWeLUCX4Ow2ig75jXiRZBbPy8HHfRWkM=; b=SqlI8V4Iyeo2AxIRd/VrV1UlbIGgEsTBjOaXXYb4qtFMLYOSFbym+U9im7u7XL4L3g i6RMLvbgSJgFgvmfffPCCbz8cznB1tbO3nA1nLZaWj9VdxdSGTqIFHQrk5pmhroGpSc8 r0pELH36mArikeqVdVLve4X6a+eoWIdjQscyePCOejyOT7E/vSemm1+gVdaowJJH4sQs QE4/4nZw5w1HWwxXZtOZ7ZmRUapmCxxo5GtJmpazPxSYaFDSDoP5r2bfdMT1gYnU85u0 h5aAUCUx/PMwR7xLxFIp8zaO3qW01ySAtfPIDUU/AqFuXPMMLAQJ9ny57GfT9CTYLhpy Xtmw== X-Gm-Message-State: ALoCoQm1JUtF3ZT8QfRdDuTqnzeMUPO9OfVcoJiyEcBYuUsWI0wpB/yi1NJK6OM9Y9eUAxyuPA99Cmx/LM3UTcYWccRT/khVdubbVgt2/irL0y2q+QwG7LGD0UkjaIvT8xAUIL4azVVbdSbfTE77BcTyJEnA+czVEWbheTFTvI3s7gbFHL/NnkrE3VSdvzZr8iI2gV2SuNNM MIME-Version: 1.0 X-Received: by 10.60.17.136 with SMTP id o8mr6355644oed.7.1379689168462; Fri, 20 Sep 2013 07:59:28 -0700 (PDT) Received: by 10.60.43.97 with HTTP; Fri, 20 Sep 2013 07:59:28 -0700 (PDT) In-Reply-To: <20130920100723.GA24605@physik.fu-berlin.de> References: <20130920100723.GA24605@physik.fu-berlin.de> Date: Fri, 20 Sep 2013 14:59:00 -0000 Message-ID: Subject: Re: (gcc/)g++ and __restrict From: Ian Lance Taylor To: Tobias Burnus Cc: "gcc-help@gcc.gnu.org" Content-Type: text/plain; charset=ISO-8859-1 X-IsSubscribed: yes X-SW-Source: 2013-09/txt/msg00131.txt.bz2 On Fri, Sep 20, 2013 at 3:07 AM, Tobias Burnus wrote: > > I was wondering how to convey to GCC that two pointers do not alias. > That works nicely in the argument list, > void foo(mytype *__restrict__ arg) > > However, it does not seem to work for C++'s member variables. Even > if one has on the class the declaration with __restrict. Neither does > casting to a restrict pointer work. I'm not sure how that could work. By definition the restrict qualifier is only meaningful in a specific context, with respect to other pointers with the restrict qualifier. It would not make sense to declare that every restrict qualified pointer in the entire program may not conflict with every other restrict qualified pointer in the entire program. That would be too limiting. What GCC implements is what the C99 standard specifies. Within a function you can have a set of restrict qualified pointers. Any write through a restrict qualified pointer may not be read through any other restrict qualified pointer (unless the second pointer is based on the first, which is defined by the standard). If we found it useful, we could introduce a new attribute for C++ class members. We could declare that within a class, all members with that attribute could not alias. But to make that useful we would have to make that attribute inheritable--we wouldn't want people to have to use it for local variables. I think it would be hard to define correctly--it was hard to define the C99 restrict qualifier. Another possibly more profitable approach would be to define a new function attribute. In functions with that attribute we would declare that none of the pointers that were not based on each other could alias. This would be difficult to use correctly but it would be fairly precise and might be sufficient for what you need. Ian