You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Because the class layout given in dramsim3.h and memory_system.h are different (the one given in public interface has no private members, which affects memory layout), when dramsim3::MemorySystem are placed on stack or within other containers, it may corrupts what's placed directly after it.
Notice that in memory_system.h there are two fields, but in dramsim3.h there is not. Is there a reason for this difference?
The problem I met is with std::optional<T>. Its implementation in g++(libstdc++) is basically as followed:
template<typename T>
classoptional<T> {
union {
struct {} _empty;
T _data;
}
bool engaged;
};
If T's apparent size is smaller than it's real size, then the mutation within T will affect engaged.
The text was updated successfully, but these errors were encountered:
CircuitCoder
changed the title
When put on stack or struct, dramsim3::MemorySystem corrupts memory
When put on stack or within struct, dramsim3::MemorySystem corrupts memory
Dec 23, 2023
Because the class layout given in
dramsim3.h
andmemory_system.h
are different (the one given in public interface has no private members, which affects memory layout), when dramsim3::MemorySystem are placed on stack or within other containers, it may corrupts what's placed directly after it.Notice that in
memory_system.h
there are two fields, but indramsim3.h
there is not. Is there a reason for this difference?The problem I met is with
std::optional<T>
. Its implementation in g++(libstdc++) is basically as followed:If
T
's apparent size is smaller than it's real size, then the mutation withinT
will affectengaged
.The text was updated successfully, but these errors were encountered: