Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ Core » Compiler warning in Topt.h L177
icon14.gif  Compiler warning in Topt.h L177 [message #60868] Fri, 27 September 2024 20:04
Didier is currently offline  Didier
Messages: 728
Registered: November 2008
Location: France
Contributor
Hello,

While compiling my app with CLANG, i ran into the following warning message (appeared with recent changes about moveable I think : didn't check git history):

/home/...../Core/Topt.h:177:9: warning: destination for this 'memcpy' call is a pointer to dynamic class 'GraphSerieDecorator'; vtable pointer will be overwritten [-Wdynamic-class-memaccess]
        memcpy(dst, src, sizeof(T));
        ~~~~~~ ^
.
.
.
/home/...../Core/Topt.h:177:9: note: explicitly cast the pointer to silence this warning
        memcpy(dst, src, sizeof(T));
               ^
               (void*)


The following minor code change silences the warning :
I just added (void*) like suggested by warning message.
is_trivially_relocatable<T> and since src and dest have same type warning can be safelly ignored.

template <class T>
inline typename std::enable_if_t<is_trivially_relocatable<T>> Relocate(T *dst, T *src)
{
	memcpy((void*)dst, (void*)src, sizeof(T));
}

[Updated on: Fri, 27 September 2024 20:10]

Report message to a moderator

Previous Topic: SMTP not working
Next Topic: Capturing memory alloc problems in Release
Goto Forum:
  


Current Time: Mon Jun 09 13:59:46 CEST 2025

Total time taken to generate the page: 0.04633 seconds