From owner-freebsd-current@FreeBSD.ORG Sun May 17 07:41:49 2015 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id ECA0ADB3 for ; Sun, 17 May 2015 07:41:49 +0000 (UTC) Received: from mail-yk0-f177.google.com (mail-yk0-f177.google.com [209.85.160.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id AE2E71F8D for ; Sun, 17 May 2015 07:41:49 +0000 (UTC) Received: by ykeo186 with SMTP id o186so45376146yke.0 for ; Sun, 17 May 2015 00:41:43 -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 :content-transfer-encoding; bh=cvrA1jnd1QonDsKoq4SbLU3ae/85PsOWBnaTDxmCK54=; b=eQY3tkDy9fCIZEMQktyMlTBFoqmuflrpklzOM6A3Wu74VgyeJkSpUplPoBSIZebaZ2 EQb8Qv6zH9q/oKZCy7BHqoEbODGNBJj1RdThzn0xlBPmZXzDV37OHBa5Nv5wdF4pMDNI wZ3FnkbbtAyN9CRI2VpuidNyYU5nlqMcb2lrRj4PgEB2f8y6mCadNWhcD0nS7hvGZUOy vZP86XAGI+t8vWLwDxYsJ5LnJX0xFSkkyjhFMnRMzXlasggByC4xBcvwJr8jKMzl2EeC inyRNfTgn1glS+3QCf+vUKt2WaGL2uBDWhXkhCmVoSiQDtepHA9LIx73mFjVWCtNm/Oz trSw== X-Gm-Message-State: ALoCoQm5qm6d/bmbfsPJtuCQD3Bls4b58tTNL7W+TJByxHOa4+QJWRZPtqDatEqGS+4jOxzl22tP MIME-Version: 1.0 X-Received: by 10.170.197.130 with SMTP id o124mr19992929yke.77.1431848057667; Sun, 17 May 2015 00:34:17 -0700 (PDT) Received: by 10.13.194.133 with HTTP; Sun, 17 May 2015 00:34:17 -0700 (PDT) X-Originating-IP: [185.65.184.50] In-Reply-To: References: <5553764A.9010202@FreeBSD.org> Date: Sun, 17 May 2015 09:34:17 +0200 Message-ID: Subject: Re: CFR: a new __unreachable() builtin From: Ed Schouten To: David Chisnall Cc: Pedro Giffuni , FreeBSD Current Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 17 May 2015 07:41:50 -0000 2015-05-13 18:09 GMT+02:00 David Chisnall : > LLVM uses this quite heavily, in a macro that expands to something equiva= lent to assert(0 && "unreachable reached!=E2=80=9D) in debug mode and __bui= ltin_unreachable() in release mode. When you=E2=80=99re debugging, you get= errors if you reach unreachable code and in deployment the compiler gets a= useful hint for optimisation. Too bad we can't use this trick in our own assert(). You'd need to define assert() like this: #define assert(expr) do { \ if (!(expr)) \ __builtin_unreachable(); \ } while (0) Unfortunately, this would cause the expression to be evaluated, which is not allowed. --=20 Ed Schouten