From owner-freebsd-arch@freebsd.org Mon May 28 18:08:05 2018 Return-Path: Delivered-To: freebsd-arch@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 0044DF74D9F for ; Mon, 28 May 2018 18:08:04 +0000 (UTC) (envelope-from rpokala@freebsd.org) Received: from mailman.ysv.freebsd.org (mailman.ysv.freebsd.org [IPv6:2001:1900:2254:206a::50:5]) by mx1.freebsd.org (Postfix) with ESMTP id 922EC79DD1 for ; Mon, 28 May 2018 18:08:04 +0000 (UTC) (envelope-from rpokala@freebsd.org) Received: by mailman.ysv.freebsd.org (Postfix) id 4DDB9F74D9D; Mon, 28 May 2018 18:08:04 +0000 (UTC) Delivered-To: arch@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 3BC08F74D9C for ; Mon, 28 May 2018 18:08:04 +0000 (UTC) (envelope-from rpokala@freebsd.org) Received: from smtp.freebsd.org (unknown [IPv6:2610:1c1:1:606c::24b:4]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "smtp.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id E5CF379DCF; Mon, 28 May 2018 18:08:03 +0000 (UTC) (envelope-from rpokala@freebsd.org) Received: from [192.168.1.4] (c-73-241-240-124.hsd1.ca.comcast.net [73.241.240.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) (Authenticated sender: rpokala) by smtp.freebsd.org (Postfix) with ESMTPSA id 66BB316D4F; Mon, 28 May 2018 18:08:03 +0000 (UTC) (envelope-from rpokala@freebsd.org) User-Agent: Microsoft-MacOutlook/10.d.1.180523 Date: Mon, 28 May 2018 11:07:59 -0700 Subject: Re: To assert() or not to assert(), that is not really a question... From: Ravi Pokala To: Poul-Henning Kamp , Message-ID: <4427091E-3B0E-4C34-B4C6-3557DD7B55E4@panasas.com> Thread-Topic: To assert() or not to assert(), that is not really a question... References: <4514.1527319154@critter.freebsd.dk> In-Reply-To: <4514.1527319154@critter.freebsd.dk> Mime-version: 1.0 Content-type: text/plain; charset="UTF-8" Content-transfer-encoding: 7bit X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 28 May 2018 18:08:05 -0000 -----Original Message----- From: on behalf of Poul-Henning Kamp Date: 2018-05-26, Saturday at 00:19 To: Subject: To assert() or not to assert(), that is not really a question... > ... > > 1. "Regular asserts" - things which are just plain wrong, which > probably means we have a genuine bug somewhere. Examples could > be null pointers where previous checks should have ensured this > not be so. Also error situations for which there is no saner > handling that killing the projcess. > > ... > > 3. "wrong asserts" - Internal state is messed up, program flow > has taken a "impossible" branch. A good example is the > default branch of a switch on a finite input set. Hi Poul-Henning, I am in strong overall agreement with your argument. I am however confused as to how (1) and (3) are different; they're both irrevocably bad internal state. Thanks, Ravi (rpokala@)