From owner-freebsd-current@FreeBSD.ORG Thu Feb 5 13:59:52 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 3797570C for ; Thu, 5 Feb 2015 13:59:52 +0000 (UTC) Received: from mail-qa0-x229.google.com (mail-qa0-x229.google.com [IPv6:2607:f8b0:400d:c00::229]) (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 E17D5E83 for ; Thu, 5 Feb 2015 13:59:51 +0000 (UTC) Received: by mail-qa0-f41.google.com with SMTP id bm13so5896763qab.0 for ; Thu, 05 Feb 2015 05:59:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc:content-type; bh=vMTwXDlPwWXTHoGEGdnzA0agg3BhFQUEa11N9R4AiXY=; b=wcZcdB7UccHQHs8BNL9pdwXxGG63CG3t+0/rmiDOWMMA34uOm7aBldWNKVqIMXoZ0m 5KQuNos43rW9lF41+EAQk8nDmIlEhqu+Yq4P0TWsloAv5BUOmVx07hvReP4q70qhXJdh SB/kqR2aoRJ93dcFnOKwNSaNqIfQzpNEOKceUpIRw5C5qeX4DAqQc8zmfmCrFV5frAJV BwC4jkDtBzvjmSKznQ405NsOvyBTHQDa5MpUvXEsU5lO+UoWgsWsfzpu546WTK4zQV8J xU+Q/943qDFdiBp087UBD0NDLIXzud7CAai18/beBx6mzewEuMSlqVy3VLTh8WRLzYU4 uNJQ== X-Received: by 10.140.37.39 with SMTP id q36mr7929438qgq.89.1423144791014; Thu, 05 Feb 2015 05:59:51 -0800 (PST) MIME-Version: 1.0 Sender: carpeddiem@gmail.com Received: by 10.140.39.209 with HTTP; Thu, 5 Feb 2015 05:59:30 -0800 (PST) In-Reply-To: References: <8089702.oYScRm8BTN@overcee.wemm.org> <20150204142941.GE42409@kib.kiev.ua> <2509923.ondFvsFdql@overcee.wemm.org> From: Ed Maste Date: Thu, 5 Feb 2015 08:59:30 -0500 X-Google-Sender-Auth: Yb-Ddq00qPOQ69p1SHCyvrFwz2U Message-ID: Subject: Re: PSA: If you run -current, beware! To: Luigi Rizzo Content-Type: text/plain; charset=UTF-8 Cc: Konstantin Belousov , "freebsd-current@freebsd.org" , Peter Wemm X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.18-1 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: Thu, 05 Feb 2015 13:59:52 -0000 On 5 February 2015 at 02:48, Luigi Rizzo wrote: > > Rather than depending on a compiler option, wouldn't it be better/more > robust to change ticks to unsigned, which has specified wrapping behavior? I believe there are cases other than ticks that rely on 2s complement signed wrap. We'd want to make sure we find such cases. Newer GCC can help with that. The -Wstrict-overflow flag causes the compiler to warn when implementing an optimization based on undefined behaviour from signed overflow. Correct C code should work with or without -fwrapv, so we can do both: enable -fwrapv, and make changes to stop relying on undefined behaviour. For ticks specifically we have many examples over time of incorrect calculations so we'll benefit from some work here, independent of signed overflow.