memory-layout Questions

3

Solved

Recently I have been trying to make a plugin for an old game, and running into a problem similar to Diamond Inheritance. I have a very reduced example, write as follows: #include <iostream> #...

3

Solved

Prior to Java 8 we had 5 major runtime data areas: Method Area Heap JVM Stacks PC registers Native method stacks With Java 8, there is no Perm Gen, that means there is no more “java.lang.Out...
Tertia asked 3/5, 2018 at 20:16

3

Solved

I have a question about the memory layout of a two-dimensional array. When we define one, just like int a[3][4], is the memory allocated to this array continuous? Or in other words, is a two-dimens...

4

Solved

Essentially, if I have typedef struct { int x; int y; } A; typedef struct { int h; int k; } B; and I have A a, does the C standard guarantee that ((B*)&a)->k is the same as a.y?
Luisluisa asked 6/11, 2013 at 5:17

3

Solved

I read this question: C++ Virtual class inheritance object size issue, and was wondering why virtual inheritance results in an additional vtable pointer in the class. I found an article here: http...
Electrophorus asked 13/8, 2019 at 17:47

3

Solved

We have some strictly typed integer types in our project: struct FooIdentifier { int raw_id; // the only data member // ... more shenanigans, but it stays a "trivial" type. }; struct ...
Neogene asked 12/3, 2021 at 9:24

2

Solved

assert_eq!(12, mem::size_of::<(i32, f64)>()); // failed assert_eq!(16, mem::size_of::<(i32, f64)>()); // succeed assert_eq!(16, mem::size_of::<(i32, f64, i32)>()); // succeed Why...
Holt asked 13/1, 2021 at 18:42

3

Solved

I just learnt about alignof and alignas C++ keywords but I can't think about any practical case where a developer would want to use these keywords. Does somebody know any practical use case for the...
Starrstarred asked 20/6, 2020 at 17:12

1

Solved

Consider the following: // Just a sequence of adjacent fields of same the type #[repr(C)] #[derive(Debug)] struct S<T> { a : T, b : T, c : T, d : T, } impl<T : Sized> S<T> { ...
Sudhir asked 7/6, 2020 at 2:15

1

Solved

I read documentation about size of enums in Swift and here is my understanding: This simple one only hold a 'tag' to differentiate cases, which is by default an UInt8 value, i.e. small = 0, medium...
Moue asked 28/5, 2020 at 10:33

2

Solved

I'm learning about the layout of executable binaries. My end goal is to analyze a specific executable for things that could be refactored (in its source) to reduce the compiled output size. I've b...
Nab asked 20/3, 2019 at 21:21

1

Solved

Is is possible to make a 1D array not C_CONTIGUOUS or F_CONTIGUOUS in numpy? I think the notion of contiguous only makes sense for arrays with more dimensions but I couldn't find anything in the d...
Collation asked 25/3, 2020 at 11:33

1

Solved

Empty base optimization is great. However, it comes with the following restriction: Empty base optimization is prohibited if one of the empty base classes is also the type or the base of the typ...
Maulmain asked 8/1, 2020 at 13:55

7

Solved

In K&R (The C Programming Language 2nd Edition) chapter 5 I read the following: First, pointers may be compared under certain circumstances. If p and q point to members of the same array, t...
Toback asked 29/12, 2019 at 2:1

2

Solved

I'm playing around with [[no_unique_address]] in c++20. In the example on cppreference we have an empty type Empty and type Z struct Empty {}; // empty class struct Z { char c; [[no_unique_add...
Indaba asked 29/11, 2019 at 17:39

3

Solved

As far as I know, the Rust compiler is allowed to pack, reorder, and add padding to each field of a struct. How can I specify the precise memory layout if I need it? In C#, I have the StructLayou...
Kedge asked 9/10, 2014 at 5:47

2

Here, in this code, the size of ob1 is 16 which is fine(because of the virtual pointer) but I can't understand why the size of ob2 is 24. #include <iostream> using namespace std; class A { ...
Vaientina asked 13/8, 2019 at 15:44

2

Solved

Does a reference have a storage location or is it just an alias for another location? Does this differ by C++ revision or is it consistent with all versions of C++? And if a reference has a storage...

7

Solved

[Not a duplicate of Structure padding and packing. That question is about how and when padding occurs. This one is about how to deal with it.] I have just realized how much memory is wasted as a re...

1

Solved

This chapter in Real World OCaml describes the runtime memory layout of different data types. However, there is no discussion on lazy values. How is lazy_t implemented, i.e., what does its runtim...
Standoff asked 25/6, 2019 at 3:16

2

Solved

See the C version of this questions here. I have two questions concerning bit fields when there are padding bits. Say I have a struct defined as struct T { unsigned int x: 1; unsigned int y:...
Slaphappy asked 20/5, 2019 at 8:7

2

Solved

Consider the following simple struct: struct A { float data[16]; }; My question is: Assuming a platform where float is a 32-bit IEEE754 floating point number (if that matters at all), does the...
Mistral asked 12/4, 2019 at 11:38

1

Solved

It appears to be smart enough to only use one byte for A, but not smart enough to use one byte for B, even though there are only 8*8=64 possibilities. Is there any way to coax Rust to figure this o...
Generosity asked 3/2, 2019 at 1:32

1

I need to get rid of this warning. As far as I understand, it appears because DerivedClass is not considered as Plain Old Data. I read cppreference about POD and Standard Layout Type but I still do...
Vanderpool asked 19/12, 2018 at 11:16

1

How does MemoryLayout calculate size for a struct ? I read this article, and I seemed to understand it pretty well, until I got stuck on the following problem: struct CertifiedPuppy1 { let age: ...
Juni asked 16/3, 2018 at 21:33

© 2022 - 2024 — McMap. All rights reserved.