From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 62114 invoked by alias); 20 Nov 2017 16:25:56 -0000 Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org Received: (qmail 62093 invoked by uid 89); 20 Nov 2017 16:25:55 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.6 required=5.0 tests=AWL,BAYES_20,KB_WAM_FROM_NAME_SINGLEWORD,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=no version=3.3.2 spammy=H*r:sk:gdb@sou, 1071, UD:remote-utils.c, PyMem_RawMalloc X-HELO: mail-ot0-f175.google.com Received: from mail-ot0-f175.google.com (HELO mail-ot0-f175.google.com) (74.125.82.175) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 20 Nov 2017 16:25:54 +0000 Received: by mail-ot0-f175.google.com with SMTP id 18so8092244oty.9 for ; Mon, 20 Nov 2017 08:25:54 -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:in-reply-to:references:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=N7/r5xTZV/J40ZZasFaPn+vnkrz3WPJtL8wiqIYVqN4=; b=QXj9AqKCmfBXjwcUK3P4G46/FS4jjTJH1vOMLA3tz/XUoTb4E7PEfOKoanOU4U30ce abbsWJqeg93W1/WFdNFr6FKaTKmSs6EGiaT/Ck9eO7oXzekuYkbsPE2Twmf2AyMM37yK C92xI2ATMR9ZhyJQMdeQftStx2gLZzWqx4i0ozhz8Ss0hEPDgiRWdPpfJcqPpSGmDSrG djG87eUdrFZtBv+KjsssUdo480CIJl1QwiqLnJ9zFxegR2Gml/wcCYQ7F33C7IKV+GBR OnzPuWFINgSb8OnPdPM/Voo+w4j7Jq4yyWZT9F92H8fLLi8YWP0XMwU/Eqx9cDTIg3k9 HPDA== X-Gm-Message-State: AJaThX6AFLsAvSWK26Y8q/fZ7E/twTqFzAfy7biZisrXnS3AT7bdGQfw VFlJPxY/nuDhohoIslDPw+jTh7copq03I7HLELTClg== X-Google-Smtp-Source: AGs4zMY4+iK6IBInJ3AePOHrlQmP/BJ77Vl8H/45kzyR6fcl2CykIFydFpjTsmxyuYqzlZeIqADXmFQhrRsXtL82i8k= X-Received: by 10.157.20.154 with SMTP id d26mr1639190ote.48.1511195152565; Mon, 20 Nov 2017 08:25:52 -0800 (PST) MIME-Version: 1.0 Received: by 10.157.81.200 with HTTP; Mon, 20 Nov 2017 08:25:51 -0800 (PST) In-Reply-To: <86r2strlrd.fsf@gmail.com> References: <86r2strlrd.fsf@gmail.com> From: Eric Gallager Date: Mon, 20 Nov 2017 16:25:00 -0000 Message-ID: Subject: Re: Fail to compile GDB with recent GCC trunk (-Werror=stringop-overflow=, -Werror=stringop-truncation) To: Yao Qi Cc: gcc@gcc.gnu.org, gdb@sourceware.org, msebor@redhat.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-SW-Source: 2017-11/txt/msg00017.txt.bz2 On 11/20/17, Yao Qi wrote: > > Hi, > I failed to compile GDB with GCC trunk (8.0.0 20171117) because of some > -Werror=3Dstringop-overflow=3D and -Werror=3Dstringop-truncation warnings. > Some of them are not necessary to me, > > 1. ../../binutils-gdb/gdb/python/py-gdb-readline.c:79:15: error: =E2=80= =98char* > strncpy(char*, const char*, size_t)=E2=80=99 output truncated before term= inating nul > copying as many bytes from a string as its length > [-Werror=3Dstringop-truncation] > strncpy (q, p, n); > ~~~~~~~~^~~~~~~~~ > ../../binutils-gdb/gdb/python/py-gdb-readline.c:73:14: note: length compu= ted > here > n =3D strlen (p); > ~~~~~~~^~~ > > the code is simple, > > n =3D strlen (p); > > /* Copy the line to Python and return. */ > q =3D (char *) PyMem_RawMalloc (n + 2); > if (q !=3D NULL) > { > strncpy (q, p, n); > q[n] =3D '\n'; > q[n + 1] =3D '\0'; > } > > I don't see the point of warning here. > > 2. ../../binutils-gdb/gdb/cp-namespace.c:1071:11: error: =E2=80=98char* > strncpy(char*, const char*, size_t)=E2=80=99 output truncated before term= inating nul > copying 2 bytes from a string of the same length > [-Werror=3Dstringop-truncation] > strncpy (full_name + scope_length, "::", 2); > ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > > full_name =3D (char *) alloca (scope_length + 2 + strlen (name) + 1); > strncpy (full_name, scope, scope_length); > strncpy (full_name + scope_length, "::", 2); > strcpy (full_name + scope_length + 2, name); > > the code looks right to me, > > Likewise, > > ../../../binutils-gdb/gdb/gdbserver/remote-utils.c:1204:14: error: =E2=80= =98char* > strncpy(char*, const char*, size_t)=E2=80=99 output truncated before term= inating nul > copying 6 bytes from a string of the same length > [-Werror=3Dstringop-truncation] > strncpy (buf, "watch:", 6); > ~~~~~~~~^~~~~~~~~~~~~~~~~~ > > strncpy (buf, "watch:", 6); > buf +=3D 6; > .... > *buf =3D '\0'; > > I can "fix" these warnings by changing GDB code, use strcpy in 1) and > use memcpy in 2). Do we expect all the users of GCC 8 changing their > correct code because GCC is not happy on the code? The warning is too > aggressive to me. > > -- > Yao (=E9=BD=90=E5=B0=A7) > I thought there was a gcc bug open about this but now I can't seem to find it; please let me know if you come across the one I was trying to remember...