+ 2

Why size of void is 1

Empty class don't have any data members but size of that is 1 as it helps to have different memory address for different objects of empty class. What's the use of 1 byte for void ? https://code.sololearn.com/cpBKea4fS3wj/?ref=app

19th May 2022, 5:44 PM
Ketan Lalcheta
Ketan Lalcheta - avatar
2 Antworten
19th May 2022, 6:49 PM
Jayakrishna 🇮🇳
+ 2
This is a side effect of GCC allowing arithmatic (addition/subtraction) on void and function pointers, as a non-standard extension. See: https://gcc.gnu.org/onlinedocs/gcc/Pointer-Arith.html
20th May 2022, 12:58 AM
Arsenic
Arsenic - avatar