From owner-freebsd-standards@freebsd.org Thu Feb 22 20:04:53 2018 Return-Path: Delivered-To: freebsd-standards@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 EB7ECF26DE3; Thu, 22 Feb 2018 20:04:52 +0000 (UTC) (envelope-from cse.cem@gmail.com) Received: from mail-io0-f175.google.com (mail-io0-f175.google.com [209.85.223.175]) (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 818AB76E07; Thu, 22 Feb 2018 20:04:52 +0000 (UTC) (envelope-from cse.cem@gmail.com) Received: by mail-io0-f175.google.com with SMTP id l12so7302895ioc.10; Thu, 22 Feb 2018 12:04:52 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:reply-to:in-reply-to:references :from:date:message-id:subject:to:cc; bh=cDdwIlb6TKmMvF/a/5buQpO0bZDmkrCbzeqjh8+WVTo=; b=WOY8ZT+atj4TFeVEPCk2byzESI8UKfMM34Gh9cSJB/7SSfyHKSdvzHiL9KHm4iRZMw USDCjpYSEfimKnrgTNwXZUAl5MITjXeX2zssNkP1YP54+CpdTXi539Z29U6tOWdBlibe 9kN6/8ynAHKzOMIvcrLByhNNyA90//iWKfVOVz5TZ5sfoPv5pTah8tfh5D8/utThBh46 2xjwaGA+fJ5EjTgTkG6yLyfMgkpC8lmhT4Ljl3ntIUcJgWZ9oqOJf71kPa5bM9tQGT/E o69+xJbtajSk/+DVFlOMWfGahXRqTJuU71pPL0URgQRoQ4N7LjUW1Ijnf0Jnk6+JH9I1 +tkw== X-Gm-Message-State: APf1xPCWt/1AF0zTGeruvzboKccuhfdwQQsUJdj0h/JOpwx/WmIfkcY8 6AJj66+iJuSJqdjgF2vqr9vY/Df8 X-Google-Smtp-Source: AH8x2262SBVRPzM88oE1/oeQvF5pbd6aD9Dq8rzDc6CFQydrtNBl1ILcCk+UJu2ZF8YbV8xv9R60Vw== X-Received: by 10.107.6.139 with SMTP id f11mr7431492ioi.23.1519329886288; Thu, 22 Feb 2018 12:04:46 -0800 (PST) Received: from mail-io0-f177.google.com (mail-io0-f177.google.com. [209.85.223.177]) by smtp.gmail.com with ESMTPSA id 30sm445350iop.73.2018.02.22.12.04.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 22 Feb 2018 12:04:46 -0800 (PST) Received: by mail-io0-f177.google.com with SMTP id v6so6191091iog.7; Thu, 22 Feb 2018 12:04:46 -0800 (PST) X-Received: by 10.107.41.16 with SMTP id p16mr10348722iop.173.1519329886009; Thu, 22 Feb 2018 12:04:46 -0800 (PST) MIME-Version: 1.0 Reply-To: cem@freebsd.org Received: by 10.2.30.149 with HTTP; Thu, 22 Feb 2018 12:04:45 -0800 (PST) In-Reply-To: References: <20180221032247.GA81670@ns.kevlo.org> <20180221104400.GU94212@kib.kiev.ua> <20180222112752.10da7e51@kalimero.tijl.coosemans.org> <20180222105608.GE94212@kib.kiev.ua> From: Conrad Meyer Date: Thu, 22 Feb 2018 12:04:45 -0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: Marking select(2) as restrict To: Eitan Adler Cc: FreeBSD Hackers , FreeBSD Standards Content-Type: text/plain; charset="UTF-8" X-BeenThere: freebsd-standards@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: Standards compliance List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 22 Feb 2018 20:04:53 -0000 On Thu, Feb 22, 2018 at 11:42 AM, Eitan Adler wrote: > On 22 February 2018 at 06:43, Warner Losh wrote: >> If the compilers affirmatively fails when this happens > > Compilers cannot fail since errors are only detectable at runtime. This is simply not true. *Some* instances of this error could only be detected at run time, but compilers can and do perform some kinds of static analysis for warning/error purposes and for optimization. In the extremely common case where fdsets are local or global variables, the compiler could easily detect when the same pointer is passed multiple times. If we're unlucky, it produces no warning and "optimizes" the undefined behavior into something awful. In my local testing, neither Clang nor GCC6 produces any error or warning for this, which is disappointing.