From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 98663 invoked by alias); 20 Nov 2017 15:51:59 -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 98587 invoked by uid 89); 20 Nov 2017 15:51:58 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.7 required=5.0 tests=BAYES_00,FREEMAIL_FROM,KB_WAM_FROM_NAME_SINGLEWORD,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=no version=3.3.2 spammy=H*RU:sk:static., Hx-spam-relays-external:sk:static., H*r:sk:gdb@sou, H*r:sk:clients X-HELO: mail-wr0-f177.google.com Received: from mail-wr0-f177.google.com (HELO mail-wr0-f177.google.com) (209.85.128.177) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 20 Nov 2017 15:51:57 +0000 Received: by mail-wr0-f177.google.com with SMTP id r2so2039840wra.13 for ; Mon, 20 Nov 2017 07:51:56 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:user-agent :mime-version:content-transfer-encoding; bh=JlU0voeRxk5Ey3vrBVjh71JUSZuVC7CBP3H3dObgvmQ=; b=aNsUAgHIs/7zfSP5HKxyMg1cKkITSKVwFm34ezlboQyEs4jzEkGg1BM/YvGdnEcPG6 MXgG9sOL2fWlOD+YAY5R6DhQ9KmBwt7wCUlgWG2fhCWhvUOgFgQJOn6i5el5z7nie3y7 swqPsDMP6rrJqQpGIHpfmOt7cO5UsYeMXLCu+scm6VgQOk0aWiZhwT4rfqv0qaZOxeMb 2z7WTxXCJwR2OzB4++admEdYgoFV85unja2IGh7ZTwE9KTm0pi32Q+n2aW/u1Y86Vo2o ZM81WXGsuATOwvV961HKoEfoTsOiIiWBpPqF5lUZt6yQbj5fRrI7jyxkIMWxszER2hUR JZNg== X-Gm-Message-State: AJaThX6AvH0mRTqpW7ZrthvJDIETSipbbI/LDNsk5R9J2iXg+Is9EFKy frYaV7PFEAXprsteY8mYvPrmOg== X-Google-Smtp-Source: AGs4zMZb8cQpkZWiqnErx1zZAtV/qSRzx12IDLugtJzgclILqcr9+GFBha9GXOWKe+Cn6ApSEw6kBg== X-Received: by 10.223.190.135 with SMTP id i7mr11650221wrh.91.1511193115281; Mon, 20 Nov 2017 07:51:55 -0800 (PST) Received: from E107787-LIN (static.42.136.251.148.clients.your-server.de. [148.251.136.42]) by smtp.gmail.com with ESMTPSA id x17sm2432305wrd.48.2017.11.20.07.51.54 (version=TLS1_2 cipher=AES128-SHA bits=128/128); Mon, 20 Nov 2017 07:51:54 -0800 (PST) From: Yao Qi To: gcc@gcc.gnu.org, gdb@sourceware.org Cc: msebor@redhat.com Subject: Fail to compile GDB with recent GCC trunk (-Werror=stringop-overflow=, -Werror=stringop-truncation) Date: Mon, 20 Nov 2017 15:51:00 -0000 Message-ID: <86r2strlrd.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-IsSubscribed: yes X-SW-Source: 2017-11/txt/msg00016.txt.bz2 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=98c= har* strncpy(char*, const char*, size_t)=E2=80=99 output truncated before t= erminating 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 compute= d 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* str= ncpy(char*, const char*, size_t)=E2=80=99 output truncated before terminati= ng 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 befo= re terminating nul copying 6 bytes from a string of the same length [-Werro= r=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. --=20 Yao (=E9=BD=90=E5=B0=A7)