From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: Re: Compiler warnings in dispnew.c Date: Sun, 28 Nov 2021 12:48:00 +0200 Message-ID: <83tufwwo7z.fsf@gnu.org> References: <87fsrg7gdt.fsf.ref@yahoo.com> <87fsrg7gdt.fsf@yahoo.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="12172"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel@gnu.org To: Po Lu Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sun Nov 28 11:48:50 2021 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mrHjl-000300-GT for ged-emacs-devel@m.gmane-mx.org; Sun, 28 Nov 2021 11:48:49 +0100 Original-Received: from localhost ([::1]:58572 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mrHjj-0003MX-Pa for ged-emacs-devel@m.gmane-mx.org; Sun, 28 Nov 2021 05:48:47 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:38430) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mrHio-0002fq-QN for emacs-devel@gnu.org; Sun, 28 Nov 2021 05:47:50 -0500 Original-Received: from [2001:470:142:3::e] (port=58346 helo=fencepost.gnu.org) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mrHio-00036e-Gw; Sun, 28 Nov 2021 05:47:50 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-version:References:Subject:In-Reply-To:To:From: Date; bh=icdDiiR+PBaRQBXlZ9ayaYxLETnuOszjVvETiK7MYwo=; b=l6XA+96hvCcpN4IfrW/W glAWMBBp9t+emBJyP/9GtF7KRXfst8Cz2mTivCUAEYDr9ys9CrF2B1Gq2nPRdaEDFan3k65prOg1+ 5QpnsKdrH+vVHpv96lu5T795V40g/09LEos6yy0g2GBiJLM/Jc/kWkGwf7VNYRU9G7fCxvhPEGpdx vfBibU9uUN7Bg/ecoh5GQf6Ayq3uhLRa93NFqmZKQlpLjfq+QMwX3VzA4GSs1iJ9+xopSvvVRq1fV Syel3Tuk2wiqcLotEcFo3SvXeALN1/yUCyD42EPh3FRa1eyZ7S8N1IZ5pkbXUT8+AA1RPk0y3bj98 mlHe5JDXq+ajCg==; Original-Received: from [87.69.77.57] (port=4912 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mrHin-0008GE-V1; Sun, 28 Nov 2021 05:47:50 -0500 In-Reply-To: <87fsrg7gdt.fsf@yahoo.com> (message from Po Lu on Sun, 28 Nov 2021 17:56:30 +0800) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:280393 Archived-At: > From: Po Lu > Date: Sun, 28 Nov 2021 17:56:30 +0800 > > Building with checking, I get: > > CC dispnew.o > In function ‘copy_row_except_pointers’, > inlined from ‘assign_row’ at dispnew.c:1050:3, > inlined from ‘mirror_make_current’ at dispnew.c:2761:3: > dispnew.c:1037:3: warning: ‘memcpy’ offset [48, 255] from the object at ‘current_row’ is out of the bounds of referenced subobject ‘x’ with type ‘int’ at offset 44 [-Warray-bounds] > 1037 | memcpy (&to->x, &from->x, sizeof *to - off); > | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > In file included from termchar.h:23, > from dispnew.c:28: > dispnew.c: In function ‘mirror_make_current’: > dispextern.h:885:7: note: subobject ‘x’ declared here > 885 | int x, y; > | ^ > > I think it would be prudent to fix this, thanks. Do you understand the problem? It looks like a compiler bug to me. We copy into the address of glyph_row->x and the size of the copy is the size of glyph_row structure minus the offset of x from the beginning. So what is wrong with that? what am I missing? When you say "building with checking", what do you mean, exactly? Did you use some non-default warning switches, and if so, which ones? And what version of GCC is that?