[bug #51281] WhenReadyInfo::WhenReadyInfo() : wrong use of memcpy()
Zdenek Sojka <[email protected]> Tue, 20 Jun 2017 17:15:27 -0400 (EDT)
| Newsgroups | gmane.comp.debugging.ddd.bugs |
|---|---|
| Message-ID | <[email protected]> |
URL:
<http://savannah.gnu.org/bugs/?51281>
Summary: WhenReadyInfo::WhenReadyInfo() : wrong use of
memcpy()
Project: DDD
Submitted by: zsojka
Submitted on: Tue 20 Jun 2017 09:15:26 PM UTC
Category: None
Severity: 3 - Normal
Item Group: None
Status: None
Privacy: Public
Assigned to: None
Open/Closed: Open
Discussion Lock: Any
Release: 3.3.12-rc2
_______________________________________________________
Details:
When compiling DDD with a recent gcc (5.4.0 in my case), the following warning
is given:
ddd.C: In constructor 'WhenReadyInfo::WhenReadyInfo(const MString&,
XtCallbackProc, XtPointer, const XmPushButtonCallbackStruct&)':
ddd.C:5825:39: warning: argument to 'sizeof' in 'void* memcpy(void*, const
void*, size_t)' call is the same expression as the destination; did you mean
to dereference it? [-Wsizeof-pointer-memaccess]
memcpy(cbs.event, c.event, sizeof(cbs.event));
The warning seems to be valid, since the memcpy() parameters are most likely
the same (dst == src), and the size is size_of_pointer.
event is unitialized (its default constructor is used; if applicable)
This patch might trigger the originally intended behavior:
+++ ddd/ddd.C 2017-06-20 23:03:48.946830931 +0200
@@ -5822,7 +5822,7 @@
}
else
{
- memcpy(cbs.event, c.event, sizeof(cbs.event));
+ memcpy(&event, c.event, sizeof(event));
cbs.event = &event;
}
}
_______________________________________________________
Reply to this item at:
<http://savannah.gnu.org/bugs/?51281>
_______________________________________________
Message sent via/by Savannah
http://savannah.gnu.org/