From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS22989 209.51.188.0/24 X-Spam-Status: No, score=-4.3 required=3.0 tests=AWL,BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_LOW, SPF_HELO_NONE,SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dcvr.yhbt.net (Postfix) with ESMTPS id 055EC1F4A5 for ; Sun, 29 Mar 2020 23:30:41 +0000 (UTC) Received: from localhost ([::1]:42696 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jIhO3-0000la-Ry for normalperson@yhbt.net; Sun, 29 Mar 2020 19:30:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36229) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jIhNz-0000jt-BE for bug-gnulib@gnu.org; Sun, 29 Mar 2020 19:30:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jIhNy-0006JM-1f for bug-gnulib@gnu.org; Sun, 29 Mar 2020 19:30:35 -0400 Received: from mail-il1-x142.google.com ([2607:f8b0:4864:20::142]:37096) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1jIhNx-0006I4-RM for bug-gnulib@gnu.org; Sun, 29 Mar 2020 19:30:33 -0400 Received: by mail-il1-x142.google.com with SMTP id a6so14091647ilr.4 for ; Sun, 29 Mar 2020 16:30:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:reply-to:from:date:message-id :subject:to:cc; bh=JobYSiPrQN4ew3IzGZsnuJEiY2bY9yx+5v2P/MCopBg=; b=AcOB9B+a/3sgiTdkHw959OR8p+eBvueN+QSpNxlfr37LZxerW518R0gi0hi/g1FpM3 kX1mjkQLGz1gjOU5QnCoBi9PCG9+YOa7QWGGDD2BiKRiO2wvwkW9eDWDk0OyzXMGKGEX Ao2mV1xpdsclRC0NqZn8WzRQCxC0tjMpUJ2El/LGDQUnxLrrR6VQwTgRrM1CusgpYHf8 pq9jSGBIQxmwNw1hl8Tb8ICRgml6R7uz2EgNuTlUMZoIg6Dj6QqgLu0Fj/FVtha88vXn su/0UscvIUNbSWhLY6vveCtEk74XnIK0WcDZKAVVRsMXIUqhpv/uJZozh5FDDWkCAGzp 6Dfw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:reply-to :from:date:message-id:subject:to:cc; bh=JobYSiPrQN4ew3IzGZsnuJEiY2bY9yx+5v2P/MCopBg=; b=Cd0QqqXa7MbZ/yjQYsu5+NKj1bCgdOlMONrYysQMH5vByCsYep1qo/dZyWmg+tuO3k x3EwjbHqNit2Lpruyzxg9lm6lWbIOYM18+DmfIOxpxxUPNzgjqNVjjeZkuCHet8zWePm JTxgZ6Vuw9snKSjYrRtJV8IlvjfPyoHV0AbmzaaLsJyc6aYeTmvz+xz186YWyt7xPDim Dt5jyS6Qu1For5QINJhCqAemVr4mEHYyQyjfpdXdPTceQuZK4GTejJuj6DZRa91E9sj+ P5fbwbnHPhd5aQohyvOkxE0O4rJH5OOV3n5FSekbWZDBrio3Qt2Frkuocq8Xo1TV5tJx Aaiw== X-Gm-Message-State: ANhLgQ1aCBEcHyZYgzwxCnPBuM1leQ1h7BmUbmA9NWQ90VW1g7xLWNyF 0BfVt6Cp5Y7wiN5x7v94xr6ZDp4pzfgoF2wuRiEDP2d9Z3c= X-Google-Smtp-Source: ADFU+vv2swcVD3IYhK02L6+6xWBGfWhTrEzIrpqHjDDtWZavTHPPyDniXhTyd3UwHJqIpQuogAC3gTDalP3j9XvHpIc= X-Received: by 2002:a05:6e02:54e:: with SMTP id i14mr9292597ils.166.1585524632930; Sun, 29 Mar 2020 16:30:32 -0700 (PDT) MIME-Version: 1.0 References: <1848192.VuvhVD494M@omega> <1665625.n3MASsG4Sn@omega> In-Reply-To: From: Jeffrey Walton Date: Sun, 29 Mar 2020 19:30:22 -0400 Message-ID: Subject: Re: test-math.c:89:3: runtime error: division by zero To: Bruno Haible Content-Type: text/plain; charset="UTF-8" X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::142 X-BeenThere: bug-gnulib@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Gnulib discussion list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: noloader@gmail.com Cc: bug-gnulib@gnu.org Errors-To: bug-gnulib-bounces+normalperson=yhbt.net@gnu.org Sender: "bug-gnulib" On Sun, Mar 29, 2020 at 7:21 PM Jeffrey Walton wrote: > > On Sun, Mar 29, 2020 at 5:59 PM Bruno Haible wrote: > > > > Jeffrey Walton wrote: > > > Let's see what the GCC folks recommend: "GCC and division by 0 under > > > sanitizers", https://gcc.gnu.org/pipermail/gcc-help/2020-March/138746.html. > > > > The way I interpret their answer > > https://gcc.gnu.org/pipermail/gcc-help/2020-March/138747.html > > is: > > 1) You need to distinguish integer division by zero and floating-point > > division by zero. > > 2) For floating-point division by zero GCC warns but should not warn. > > You should enter a bug report about this. > > 3) The undefined-behaviour sanitizer should report integer division by zero > > but not floating-point division by zero ("as it can be a legitimate way > > of obtaining infinities and NaNs"). > > > > In the gnulib code, test-math.c:89, we clearly have a floating-point > > division by zero. > > Yeah, GCC looks partially clean. It is not producing a sanitizer > finding, so I guess no blood, no foul. > > Clang is a problem: https://bugs.llvm.org/show_bug.cgi?id=45352. Here's a workaround, but I think it looks like fido's ass: $ cat test.c #include #include #if defined(__clang__) # define CLANG_NO_DIV_BY_ZERO __attribute__((no_sanitize("float-divide-by-zero"))) #else # define CLANG_NO_DIV_BY_ZERO #endif CLANG_NO_DIV_BY_ZERO int main(void) { return INFINITY == 1.0f / 0.0f ? 0 : 1; } $ clang -fsanitize=undefined test.c -o test.exe $ ./test.exe $ clang --version clang version 6.0.0-1ubuntu2 Would you be willing to hide a macro like CLANG_NO_DIV_BY_ZERO in a header somewhere so it can be used in tests like test-math.h? Jeff