[Bug other/54800] New: libiberty/simple-object-mach-o.c:704: possible optimisation ?
dcb314 at hotmail dot com
gcc-bugzilla@gcc.gnu.org
Wed Oct 3 21:21:00 GMT 2012
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54800
Bug #: 54800
Summary: libiberty/simple-object-mach-o.c:704: possible
optimisation ?
Classification: Unclassified
Product: gcc
Version: 4.8.0
Status: UNCONFIRMED
Severity: minor
Priority: P3
Component: other
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: dcb314@hotmail.com
I just tried the latest cppcheck over the source code
of trunk and it said
[trunk/libiberty/simple-object-mach-o.c:704] ->
[trunk/libiberty/simple-object-mach-o.c:705]: (performance) Buffer 'namebuf' is
being written before its old content has been used.
The source code is
memset (namebuf, 0, MACH_O_NAME_LEN * 2 + 2);
memcpy (namebuf, (char *) sechdr + segname_offset, MACH_O_NAME_LEN);
Maybe something like
memcpy (namebuf, (char *) sechdr + segname_offset, MACH_O_NAME_LEN);
memset (&namebuf[MACH_O_NAME_LEN], MACH_O_NAME_LEN + 2);
might be faster and simpler ?
More information about the Gcc-bugs
mailing list