From owner-svn-src-head@freebsd.org Sat Jan 20 01:11:03 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 62CCCED3A05 for ; Sat, 20 Jan 2018 01:11:03 +0000 (UTC) (envelope-from marklmi26-fbsd@yahoo.com) Received: from sonic301-2.consmr.mail.bf2.yahoo.com (sonic301-2.consmr.mail.bf2.yahoo.com [74.6.129.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 2D9E4800CB for ; Sat, 20 Jan 2018 01:11:02 +0000 (UTC) (envelope-from marklmi26-fbsd@yahoo.com) X-YMail-OSG: d2BSD6UVM1n_bKLChx2YuqONdAeKH55pzEFuOKM8Jq7T3VDzp_a5RlJ8_rEC.xw eCnvpJqqVjnMTgCkXwSYjxn1QKNH_gsE19OUyfpTOVwAVYIQWJifNGxhgbtxeukJkr1I.3vFqb07 CBsk3r7Cw5S0Rtq3wtgaXm5VS0C3k77t5cF7uP1FZGHVtDA499CxIqPrnH_VPEd63Tte5yUhyLUu P2kYzRpjzOJktFSrLLPgHjiRGfaFuEi2FjwNVYMDgMX47epXskfUORdlObAiTcv593KI1.A4dIt3 OWtiwelojkJZgclIwNTh9qqxYNoyJcdpZ2TmQ9At6_erszjSIqraHGsXYTXxry8DKkp6kNboP3Fu pn.47vZW3ighNtTiF.5TKmvbKVatq2lJiJZk2nga2CeZbRL0WgpXdthmFCFdJmpQm1nUoq2Sr.o8 A14GsjMTeULomawI9a.cR_lm9OqBNp7Dhp8oueP6X94VRLEv2c5bUpiBeCjFO5XHBivZc Received: from sonic.gate.mail.ne1.yahoo.com by sonic301.consmr.mail.bf2.yahoo.com with HTTP; Sat, 20 Jan 2018 01:10:56 +0000 Received: from smtp109.rhel.mail.bf1.yahoo.com (EHLO [192.168.1.25]) ([98.139.233.82]) by smtp413.mail.bf1.yahoo.com (JAMES SMTP Server ) with ESMTPA ID 2d540455da77359e78b388f38159c536; Sat, 20 Jan 2018 01:10:51 +0000 (UTC) From: Mark Millard Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Mime-Version: 1.0 (Mac OS X Mail 10.3 \(3273\)) Subject: Re: svn commit: r328159 - head/sys/modules Message-Id: <837BD7D7-63C9-4C87-AFCB-DE6CC2591011@yahoo.com> Date: Fri, 19 Jan 2018 17:10:49 -0800 To: "Conrad E. Meyer" , bjkfbsd@gmail.com, svn-src-head@freebsd.org X-Mailer: Apple Mail (2.3273) X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 20 Jan 2018 01:11:03 -0000 Conrad Meyer cem at freebsd.org wrote on Fri Jan 19 05:07:22 UTC 2018 : > The spec says the behavior is undefined; not that the compiler has to > produce a warning or error message. The compiler *does* get to > arbitrarily decide what it wants to do when it encounters UB. It is > wholly free to implement this particular UB with the logical result > and no warning/error. This is partially correct and partially probably-not, at least for C99. 6.5.7 of C99 does say the constraint and the undefined status that results for the left shift issue in question (and the right shift for that matter): "If the value of the right operand is negative or is greater than or equal to the width of the promoted left operand, the behavior is undefined." But 5.1.1.3 says about Diagnostics: "A conforming implementation shall produce at least one diagnostic message (identified in an implementation-defined manner) if a preprocessing translation unit or translation unit contains a violation of any syntax rule or constraint, even if the behavior is also explicitly specified as undefined or implementation-defined." The relevant part of 6.5.7 from what I quoted does specify a "constraint" with undefined behavior, section 3.8 defines "constraint" via: "restriction, either syntactic or semantic, by which the exposition of language elements is to be interpreted" Notes: My stated view presumes that known compile-time-constants are to be checked at compile time for constraint violations but proving absence of run-time problems is not to be done at compile time. The difference between "diagnostic" and the more specific alternatives "warning" and "error" leave some room that I ignore here. === Mark Millard marklmi at yahoo.com ( markmi at dsl-only.net is going away in 2018-Feb, late)