Received: by 10.213.65.68 with SMTP id h4csp845941imn; Tue, 20 Mar 2018 17:32:26 -0700 (PDT) X-Google-Smtp-Source: AG47ELvEs9g0b9NUIDT6yoQDSBYq9n5dBq50g4Y3XtePMGor4kJkymO/IiiV7j/jVGgZfTu0gGmM X-Received: by 10.99.147.25 with SMTP id b25mr5627075pge.309.1521592346880; Tue, 20 Mar 2018 17:32:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521592346; cv=none; d=google.com; s=arc-20160816; b=U6BMQ3R74Rrw4RxSfecKWnf0DIZThIhXv3qfvzhi6fyIqGKgIyJsMjUOlmVrx7ozAH irU+eCuhDMxpPPWA+q8PUn4ATU8Utv0I8iNq/++5G1hdP1kYPa30l4BtVqkEtlFBherR pENCUEeUj0C92R4G9wJzoY+HV5ZtzYNEBeSMiDDIJWQIJvoG84sNvJcpSV40h2sPYFk4 WUGmuMY7vlWfMOMMMCtUNA4LytrhUdOPNqwFuywNRbdSFUCSSxILkJKFfK2g7QXb4lrV Qr8YdSWkf4RxPQumxtw2tmOUSFXb74EHcs3WOshUK4XtWC1YdsUp4QuqzGQ5gzhy4x7b CY5Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature:dkim-signature :arc-authentication-results; bh=4xKJqF51MA9UAlOCJK4M0R5pTYE3EG7i0oIOw1GqKak=; b=ADpChNVF47Hm6oO0pm1z0lS/s6vs/Qht2Rv2XJw06yRxzAutgmkeum9N6hLeI+YyBR H4L7B3DO2DhdZrXGnApsARsV3SpvYOyNgCMOJffA/tSQdcUh0OqK6zUeItQK0XlSUOtD qYLJglzFLGMxWqJDfGpUl5oH69Jzl788G8HNH6Hm58zKh+pI/Pq/PvGFXUuf/gAL0n00 osgGGX957FpIZVkzfWG7n6WNjvWtQ4XPMK5VJy/4zLtvlutfY7o8+ZDFGGXOQQLmS5VB AAmHlmrb5mKHEvblaT/0zE5oU86gnQjEofpBnhH9J4XwUoTyJSk++XOH49fpBDAVkWfS s4yg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=hNiTs1lN; dkim=fail header.i=@linux-foundation.org header.s=google header.b=L3SWrmaB; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 189si1942145pgc.616.2018.03.20.17.32.00; Tue, 20 Mar 2018 17:32:26 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=hNiTs1lN; dkim=fail header.i=@linux-foundation.org header.s=google header.b=L3SWrmaB; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751512AbeCUAal (ORCPT + 99 others); Tue, 20 Mar 2018 20:30:41 -0400 Received: from mail-io0-f179.google.com ([209.85.223.179]:45254 "EHLO mail-io0-f179.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751396AbeCUAaj (ORCPT ); Tue, 20 Mar 2018 20:30:39 -0400 Received: by mail-io0-f179.google.com with SMTP id 141so4553315iou.12 for ; Tue, 20 Mar 2018 17:30:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=4xKJqF51MA9UAlOCJK4M0R5pTYE3EG7i0oIOw1GqKak=; b=hNiTs1lNU934nWkaYdiECer4V4/fw6C0uu4o7UAblIhnj308FZ00YUgRC1Kso8qbff RQn3aCu6WQq96IVcH9duR4460Gou9F6zPiM73R2+5an6BQm8LZ2y/C5fCsKFkQPwTISr c6jQ4FN6aGTxb812eplDg6bMDYGeGWjJ36DoBx4U4cKBCaQnWSo2uSkpcaCOvLJXvf9H Nm+at/6uAuxIQQ/2U2t1fS/pBKRBEwoDmOnDBbDJqr6avlGtOJA5j0cudTaGe5IcSjm2 RS5dohAPH30zkX3upRoR4SN7UweL+vHNtW+U94Gfz9qeNyqo9tHJzLmdkSY1vm8dy+Pb 2oLw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=google; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=4xKJqF51MA9UAlOCJK4M0R5pTYE3EG7i0oIOw1GqKak=; b=L3SWrmaBTg+IjhCHXZsJV0coMnV8jD9jGyjTVl1rmysasyTpHs2UDWxki/6gA4CdUt Lm07ocbbXWYwNppDyTBvV8X9rpkBBJGBDj/D47J/grTZOAg6ZeeqPJIi0CTkYJW5Xc4v DDRAKd0BoisOdqcyCUOsIGU5y5aEgauIt36ek= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=4xKJqF51MA9UAlOCJK4M0R5pTYE3EG7i0oIOw1GqKak=; b=Nzm+955ubo44vXjBuQOQpUkgBDGxFPRjkM82vgVjsahuCpehNKC9v8QlQXe1eMtyFQ GAXfaN2wMrLMO3vDwk8+jSwlto6EXjBfngvdZQVO78rNgT9EAieBBOWMkhEv3urqQkIz vs1uPZcLI+fUJnCMSHw0pCqWd3K0VESsg53bEXEw1N/GvAjDBmp4RJRVrYUcIqYdLSSX Tbp3y8AcsjBDMO5RT2Ce5qcplrxJBeObl8RvcaUTOVj72KX4qT7kAwijvOnFu950iBMF XiRDRNCDH0aKFdoI4bFU3p90+6JWJpHtX9rVm1bleuDURChOmPNqPtGob7EiIdfzRA0z qvUA== X-Gm-Message-State: AElRT7GjNeg2z1rZDpchULIpwmrM4G4T1RFkSiWzNX1REYLunZ4bicTT JD96fejKnES2qVhC3ymqHjqzO2Hj8MbpDhkAofA= X-Received: by 10.107.182.214 with SMTP id g205mr19530216iof.203.1521592238706; Tue, 20 Mar 2018 17:30:38 -0700 (PDT) MIME-Version: 1.0 Received: by 10.107.95.15 with HTTP; Tue, 20 Mar 2018 17:30:38 -0700 (PDT) In-Reply-To: <1521591040.508.2.camel@med.uni-goettingen.de> References: <1521584015.31174.3.camel@med.uni-goettingen.de> <1521591040.508.2.camel@med.uni-goettingen.de> From: Linus Torvalds Date: Tue, 20 Mar 2018 17:30:38 -0700 X-Google-Sender-Auth: cLLzlYIhB1jKascG09zi2uGfjPY Message-ID: Subject: Re: detecting integer constant expressions in macros To: "Uecker, Martin" Cc: "linux-kernel@vger.kernel.org" Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Mar 20, 2018 at 5:10 PM, Uecker, Martin wrote: > >> >> So I see two issues: >> >> - "sizeof(*(void *)1)" is not necessalily well-defined. For gcc it >> is >> 1. But it could cause warnings. > > It is a documented extension which enables pointer arithmetic > on void pointers, so I am sure neither gcc nor > clang has any problem with it. Well, so sparse does the whole "void pointer arithmetic" thing too, but sparse actually complains about use of sizeof(void). We could remove that warning, though. But: > But one could also use __builtin_types_compatible_p instead. That might be the right approach, even if I like how it only used standard C (although _disgusting_ standard C) without it apart from the small issue of sizeof(void) So something like #define __is_constant(a) \ __builtin_types_compatible_p(int *, typeof(1 ? ((void*)((a) * 0l)) : (int*)1 ) ) if I counted the parentheses right.. Linus