Received: by 2002:ac0:8c8e:0:0:0:0:0 with SMTP id r14csp19498ima; Wed, 6 Feb 2019 16:17:44 -0800 (PST) X-Google-Smtp-Source: AHgI3Ibx957IAC8wk8ZZMbcI7BkAvKCUMlzlm5Vo/W56QE9gMwxKXzbAjXNSUVBl0/pj7c4zTAr0 X-Received: by 2002:a63:c40a:: with SMTP id h10mr10643631pgd.131.1549498664217; Wed, 06 Feb 2019 16:17:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549498664; cv=none; d=google.com; s=arc-20160816; b=dlMyR9P/5gVKXlAOD1MQfKT9XVMydk6Sc4rB752TKa5ecfFloPxLzjoArH4JwtOq3j E78vEvuRVlEoLviWCxo3sW3IfF+nSj/NpsWsulVUdTJjHYy5MS5mzXzMDw+0cO2fZBIj zvtZnHzo43JksOL7lj6C64Rtzd2bo8bq6fJ1LByMTo3eUE8IN8OI14Nr9qIGJg0Y9NQI QZgTfWJQImp5UZ8m2+t7zPdGhW2tPWdc3YW+GXAPgPINDbn1ooYcQMgA+NMnuEiVxYmR 4A5ADruTLW24azYSMIJtPXospzElyyV6SID4UWTwzufUhYXQ1rY3vuVxJaNUmhjRKGdB jWUw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=yje4amOcq5mO6LIgG8ElJEar7nMZ/c/udNFZT9sHtWk=; b=otL7XJg/+iLlQgwIa87rNyvMR1+kAP3ejopBYfVtjtrLOLYEVKcwmFiJv2EgH2FhWi P+jluBkHwjgOPwvsErCdEHL644Th3zrZAyvrxgFtr60BL6RLcpYM4RDcDk+BT9rBFCCD CxhA1FxNfSs9WgV+aaEHJUAR99eDAsRKN2CDt8hWkVRjI4vXwv7MKMFIVzgHg5zqGCXY vL5VjYe9xRva7E1Ob/0olJn6hgw0Y1swiMrfjqULS1Rr8Fx8fFEzEM05agpodo9qMNg2 Ye4EGGPLzQdbK/K4kMC3z2qYpY09w6Q8k5fUwYgp0/wm7VDc0phnkSxwmCvzVbcJBFj8 Kbsw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=rYm3pwTq; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 9si731562pfq.129.2019.02.06.16.17.20; Wed, 06 Feb 2019 16:17:44 -0800 (PST) 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=pass header.i=@google.com header.s=20161025 header.b=rYm3pwTq; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726606AbfBGAPM (ORCPT + 99 others); Wed, 6 Feb 2019 19:15:12 -0500 Received: from mail-pl1-f194.google.com ([209.85.214.194]:44078 "EHLO mail-pl1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725959AbfBGAPM (ORCPT ); Wed, 6 Feb 2019 19:15:12 -0500 Received: by mail-pl1-f194.google.com with SMTP id p4so3906359plq.11 for ; Wed, 06 Feb 2019 16:15:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=yje4amOcq5mO6LIgG8ElJEar7nMZ/c/udNFZT9sHtWk=; b=rYm3pwTqyB/byqalgLbzHR4GMWJvAH+wWxmY/4wty0tnnkXuo+14gHxt+0AEmqRpCn IqdJwHRiUQbil/ooSUjvVCPvbayGMlHWEleuJiiVXYCiDKo+p5FK2Tt4NQNjq2Iy+cXy yXwnkdcNAnFcD+5y1PK1uo3+uD6VbWdgdNIo5IXSw/Wjg0HNLlvczFzufmBF/e1fn5PM zz2TT0bcLdl9gXca5zaSwyCMxzA2UsIKcG21OZVfOnQUTM0GiiwwyqIJdawGYyrsbC+X yn/OUTUCADZI5K46fFKQeQDXHAfIC+aBfT4byKC7b+/X12cr3dadoxXJsYpZm1iI/DMu sSoA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=yje4amOcq5mO6LIgG8ElJEar7nMZ/c/udNFZT9sHtWk=; b=ldGHGgslIYrAMWp0kwNV/Nnl6wz0FG1YAa4J/A/lwyTt9hT340sgafasAUXJV+omrC fJMSRCRiKBh5GPOPHn3RNWKSZnxQao0tj6zWzNQWAZW170PRsdLKh9lUD/GG0Esm4ac/ u8zxjdr+mRHwBnang5pFJo3eNy9Pr1XsJKxOhw9g5Wv0EsELN5Xm+TIwfILykBAOBsvO b/sPXou0ba4iBVtsRlV4IAGkvOGo4bRDDPohSDph5G7C8KO6Z2I7KxRMYVpN//B46BhM MyD3FSLbJqV03QtbcGMKbPCCQ5ORnLqz7F/XNUrJd3waLCnGDqFrABtyEkRa54/+nDSn YxCw== X-Gm-Message-State: AHQUAua5+VReY9/ua8XGXEs0xtZ2lHmHMv0QK5Ix2psV7sN2tnyJRgpc RhErO6OGKmJX+3isyVdid2EOutb2lT31d0tLuCBe5A== X-Received: by 2002:a17:902:4464:: with SMTP id k91mr13673903pld.13.1549498510952; Wed, 06 Feb 2019 16:15:10 -0800 (PST) MIME-Version: 1.0 References: <20190203192401.29170-1-linux@rasmusvillemoes.dk> In-Reply-To: From: Nick Desaulniers Date: Wed, 6 Feb 2019 16:14:55 -0800 Message-ID: Subject: Re: [PATCH] build_bug.h: add wrapper for _Static_assert To: Rasmus Villemoes Cc: Masahiro Yamada , Kees Cook , Andrew Morton , Luc Van Oostenryck , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Feb 5, 2019 at 1:38 AM Rasmus Villemoes wrote: > > On 05/02/2019 09.05, Masahiro Yamada wrote: > > On Mon, Feb 4, 2019 at 4:24 AM Rasmus Villemoes > > wrote: > >> +#define static_assert(expr, ...) __static_assert(expr, ##__VA_ARGS__,= #expr) > >> +#define __static_assert(expr, msg, ...) _Static_assert(expr, "" msg "= ") > > > > What is the "" "" for? > > Good point. It's a leftover from when I had a fallback-implementation of > _Static_assert for gcc < 4.6, where I wanted to ensure that the second > argument was a string literal, even if my fallback implementation > ignored that argument. Now it's actually a little harmful, because I had assumed it was for the "optional" part of the error message, since whether you pass a string error message or not, the C preprocessor should join them all together? > > foobar.c:5:34: error: expected string literal before =E2=80=98expected=E2= =80=99 > static_assert(sizeof(long) =3D=3D 8, expected 64 bit machine); Hopefully you'd put `expected` in double quotes? Note: I'm _very_ happy to see this being added. Once it's landed, I too can think of some places that it would work better than BUILD_BUG_ON(). --=20 Thanks, ~Nick Desaulniers