sizeof()
will only work for a fixed size array (which can be static, stack based or in a struct).
If you apply it to an array created with malloc
(or new in C++) you will always get the size of a pointer.
And yes, this is based on compile time information.