From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 36732 invoked by alias); 19 May 2017 16:07:08 -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 36698 invoked by uid 89); 19 May 2017 16:07:07 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.1 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_NONE,RCVD_IN_SORBS_SPAM,URIBL_RED autolearn=no version=3.3.2 spammy= X-HELO: mail-wr0-f170.google.com Received: from mail-wr0-f170.google.com (HELO mail-wr0-f170.google.com) (209.85.128.170) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 19 May 2017 16:07:06 +0000 Received: by mail-wr0-f170.google.com with SMTP id w50so19869473wrc.0 for ; Fri, 19 May 2017 09:07:09 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:cc:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding; bh=HeP+LXr3wUFmgqoCcZxHJTakESriddPF1VN30tQEYfs=; b=djxP2dg2al1i4ILPkytRmu7Orgnbv5bpImxbNfEsQCVWAolemGm4Hl5WmTlZ3+plAn 0Mu2uk9MTzHM8YVXq3EGbFrqToA5ZDmmvR+L9j7lX2fJ3svr+tUY+bbRCxniOr/h9Q/3 P+zMUsA50RLfH2z7znko8FMGzIrzr1WOnAbjsNnW8I2aR8+yUbKmW4azwpmXFVyIgUVE ab2lJXF7aEMIbWwb9h1U0G6ZwB55xSSIJfZWWFORDY7SV8ApjbgYCDYs5uAOAQRofy79 GZRn0O4NmH1ME8elKNKFcVNOkjtKculj6xG2WDJCcE7/du3bEc/rJwnBMdR1NyW6WC8R 7KLA== X-Gm-Message-State: AODbwcDeMHaRci1ro8V/7yRqIxqLAftwaPcmoaasbGkCpn6TXAveffaG nFcU6IU13qhk/I8y X-Received: by 10.223.170.195 with SMTP id i3mr4313420wrc.49.1495210027753; Fri, 19 May 2017 09:07:07 -0700 (PDT) Received: from [192.168.0.102] ([37.189.166.198]) by smtp.gmail.com with ESMTPSA id p107sm2849599wrb.64.2017.05.19.09.07.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 19 May 2017 09:07:06 -0700 (PDT) Subject: Re: MinGW compilation warnings in libiberty's xstrndup.c To: Eli Zaretskii References: <83h90vcqo6.fsf@gnu.org> <60a354b0-6c1a-15ea-177a-8bdb198c8c03@redhat.com> <83a8683ler.fsf@gnu.org> Cc: gcc-patches@gcc.gnu.org, gdb-patches@sourceware.org, thomas@codesourcery.com From: Pedro Alves Message-ID: Date: Fri, 19 May 2017 16:08:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: <83a8683ler.fsf@gnu.org> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-SW-Source: 2017-05/txt/msg01592.txt.bz2 On 05/19/2017 04:40 PM, Eli Zaretskii wrote: >> Cc: gdb-patches@sourceware.org, Thomas Schwinge >> From: Pedro Alves >> Date: Fri, 19 May 2017 16:22:55 +0100 >> >> But then, xstrndup.c has at the top: >> >> #ifdef HAVE_STRING_H >> #include >> #else >> # ifdef HAVE_STRINGS_H >> # include >> # endif >> #endif >> >> So I would expect your build to pick the strnlen declaration from >> one of the string.h or strings.h mingw headers. Why didn't it? > > Because MinGW doesn't have it, not unless you build a program that > will require one of the newer versions of the Windows C runtime > library. That's why libiberty's strnlen is being compiled in the > MinGW build in the first place. OK, I didn't realize there was a strnlen replacement too. > > Specifically, the MinGW headers do provide a prototype for strnlen if > the program defines __MSVCRT_VERSION__ to be a high enough version, or > defines _POSIX_C_SOURCE >= 200809L, but none of these is set by > default, and is not a good idea, as explained above, for a program > that needs to run on a wide variety of OS versions. > > IOW, libiberty shouldn't rely on the system headers to provide a > strnlen prototype when libiberty's strnlen is being included in the > library as a replacement. OK, I guess then we're up to figuring out which direction to go. Either an AC_CHECK_DECL is missing on libiberty's configure, or the original patch really wanted AC_CHECK_FUNC instead of AC_CHECK_DECL. Or something else, I only look at libiberty's configury every couple of years and forget how this is all supposed to work in between. Thanks, Pedro Alves