From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 16096 invoked by alias); 6 Jun 2018 00:39:37 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 16081 invoked by uid 89); 6 Jun 2018 00:39:36 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.4 required=5.0 tests=AWL,BAYES_00,KAM_SHORT,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.2 spammy=4.3, 10.5 X-HELO: mail-oi0-f67.google.com Received: from mail-oi0-f67.google.com (HELO mail-oi0-f67.google.com) (209.85.218.67) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 06 Jun 2018 00:39:34 +0000 Received: by mail-oi0-f67.google.com with SMTP id c6-v6so2747804oiy.0 for ; Tue, 05 Jun 2018 17:39:34 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=TvHcpMyTamWi+iu880pu55+HB7uDzkh67M8rCHsd9Es=; b=W+0RJczCi2OtZF5Dx58pY8B3vCtfTVz0BB3zTwvraURXM0SZB3RG9Khp2gVuuo6Xrn 2vMRoq23MczyskAxDRDVgVGeX5ZXHDT1ray0oJjpZl2zEMCxu46BHql3+tdhgBLOpZnJ QufTUHd4CV9bsqyaymLSEpTwIKjReNbyNuwH7Liw7r5/8fP2vs5a/5elVWtXuVu3xoEA JFJgJp/FP4obfVxnvf5DgWfxuvC5j/iKMySKvIp4KtkIckpa5RBfWOv6QhEWEAi5SSur FAVIOdMX/L5/45DRzCoLy6S5XUDQ90NhYrTRqsl3r4IWqbTt0zmFerjMvPbu85Hosdd1 ZXzA== X-Gm-Message-State: APt69E0lYNkwvMstyEJXg6poQ4/J/EEOP9U8EEma6bSQonizgNsNUyw9 H7DDb86+7XB3XcwX3iVLFv7u3KcIjDhnTzMdnQ95Zg== X-Google-Smtp-Source: ADUXVKJ0Ze4sCim1865fCvvoRTRiwJakCAg7IofPyBcz5SVOksPA1VTSSxeertrwP2/VCQMk9NnaJwr4syq0E8pWURQ= X-Received: by 2002:a54:4004:: with SMTP id x4-v6mr492460oie.162.1528245572948; Tue, 05 Jun 2018 17:39:32 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a9d:2cb8:0:0:0:0:0 with HTTP; Tue, 5 Jun 2018 17:39:32 -0700 (PDT) In-Reply-To: References: From: Eric Gallager Date: Wed, 06 Jun 2018 00:39:00 -0000 Message-ID: Subject: Re: [PATCH] add support for strnlen (PR 81384) To: Martin Sebor Cc: Gcc Patch List Content-Type: text/plain; charset="UTF-8" X-IsSubscribed: yes X-SW-Source: 2018-06/txt/msg00277.txt.bz2 On 6/5/18, Martin Sebor wrote: > The attached patch adds basic support for handling strnlen > as a built-in function. It touches the strlen pass where > it folds constant results of the function, and builtins.c > to add simple support for expanding strnlen calls with known > results. It also changes calls.c to detect excessive bounds > to the function and unsafe calls with arguments declared > attribute nonstring. > > A side-effect of the strlen change I should call out is that > strlen() calls to all zero-length arrays that aren't considered > flexible array members (i.e., internal members or non-members) > are folded into zero. No warning is issued for such invalid > uses of zero-length arrays but based on the responses to my > question Re: aliasing between internal zero-length-arrays and > other members(*) it sounds like one would be appropriate. > I will see about adding one in a separate patch. > > Martin > > [*] https://gcc.gnu.org/ml/gcc/2018-06/msg00046.html > I see stuff in the patch mentioning the library version of strnlen; have you tested on platforms both with and without strnlen in their libcs? The gnulib documentation lists these platforms as having missing or buggy strnlens: This function is missing on some platforms: Mac OS X 10.5, FreeBSD 6.0, NetBSD 5.0, OpenBSD 3.8, AIX 4.3.2, HP-UX 11, IRIX 6.5, OSF/1 5.1, Solaris 10, mingw, Interix 3.5. This function is buggy on some platforms: AIX 4.3. https://www.gnu.org/software/gnulib/manual/html_node/strnlen.html