From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 1AA923858CDB; Tue, 16 Apr 2024 22:19:57 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1AA923858CDB DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1713305998; bh=6SukdIn0FSVGNAPj7nO6KXtMdVtI39vwAH6sSqMBwbo=; h=From:To:Subject:Date:In-Reply-To:References:From; b=Pg79gzoRreqZZGT8REwwa3hwdYJ0ZIxOpZoSNr/e9RvipJGOlByOSfHK+d4kS0HZF TxMqKCQBVxH1kxl84uzQN0ahhEARKAenopZcg4GmyLzxQ3cODwA5d1r6JcNJ6a5uOC klL6TMscXPi2++5biS9WKrbScS+LTGznUVtXB+AU= From: "peter0x44 at disroot dot org" To: gcc-bugs@gcc.gnu.org Subject: [Bug libfortran/112364] calloc used incorrectly Date: Tue, 16 Apr 2024 22:19:48 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: libfortran X-Bugzilla-Version: 14.0 X-Bugzilla-Keywords: build, diagnostic, easyhack, internal-improvement X-Bugzilla-Severity: normal X-Bugzilla-Who: peter0x44 at disroot dot org X-Bugzilla-Status: RESOLVED X-Bugzilla-Resolution: FIXED X-Bugzilla-Priority: P4 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: cc Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D112364 Peter Damianov changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |peter0x44 at disroot dot o= rg --- Comment #14 from Peter Damianov --- ../../gcc/gcc/../libgcc/libgcov-util.c: In function 'void tag_counters(unsi= gned int, int)': ../../gcc/gcc/../libgcc/libgcov-util.c:214:59: warning: 'void* calloc(size_= t, size_t)' sizes specified with 'sizeof' in the earlier argument and not in t= he later argument [-Wcalloc-transposed-args] 214 | k_ctrs[tag_ix].values =3D values =3D (gcov_type *) xcalloc (sizeof (gcov_type), |=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20 ^~~~~~~~~~~~~~~~~~ ../../gcc/gcc/../libgcc/libgcov-util.c:214:59: note: earlier argument should specify number of elements, later size of each element ../../gcc/gcc/../libgcc/libgcov-util.c: In function 'void topn_to_memory_representation(gcov_ctr_info*)': ../../gcc/gcc/../libgcc/libgcov-util.c:529:43: warning: 'void* calloc(size_= t, size_t)' sizes specified with 'sizeof' in the earlier argument and not in t= he later argument [-Wcalloc-transposed-args] 529 | =3D (struct gcov_kvp *)xcalloc (sizeof (struct gcov_kvp= ), n); | ^~~~~~~~~~~~~~~~~~~~~~~~ ../../gcc/gcc/../libgcc/libgcov-util.c:529:43: note: earlier argument should specify number of elements, later size of each element I found a two more instances of this in libgcov-util.c Personally I don't agree with this warning at all, it's FAR too spammy for = what it is, considering it never actually catches a real defect, but rather a mi= nor style choice that (IMO) does not affect readability in any case. Whether I = see sizeof in the first or second argument doesn't affect my understanding of t= he code. In a static analyzer, fine, but I think in GCC, no. But I guess the same solution should be taken for this one, too, if it's an issue in libgfortran also.=