[Bug c++/28820] sizeof == 0 for empty class

pinskia at gcc dot gnu dot org gcc-bugzilla@gcc.gnu.org
Tue Sep 12 08:01:00 GMT 2006



------- Comment #5 from pinskia at gcc dot gnu dot org  2006-09-12 08:01 -------
class A
{
public:
        int a[0];
};


This class is not empty, it contains a (GNU) variable sized array so the size
of zero is correct for this extension.  The reason why it is zero is because
the array size is zero, this allows for the correct caculation when doing
sizeof(A)+sizeof(int)*n for malloc and/or new.


-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|WAITING                     |RESOLVED
         Resolution|                            |INVALID


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28820



More information about the Gcc-bugs mailing list