I\'ve been reading about this stuff that size of an object should be at least 1 byte (C++: What is the size of an object of an empty class?) and what\'s wrong about having t
C++ has (among other things) a rule that says pointers to objects compare equal if and only if the pointers refer to the same object. Under the scenario you propose, this would no longer be true.
There's also quite a bit of code that simply assumes sizeof
will also produce a strictly positive result. Jut for example, quite a bit of code uses things like:
#define elements(array) ((sizeof(array)/sizeof(array[0]))
For objects with a size of zero, this would result in 0/0
, which is mathematically undefined.
Rather than make changes everywhere else to support one corner case, it was a lot simpler to simply eliminate the corner case so it fit with existing rules.