Re: sizeof
Russell Shaw <[email protected]>
| Newsgroups | gmane.comp.gdb.devel |
|---|---|
| Message-ID | <[email protected]> |
On 11/5/22 18:16, Russell Shaw wrote: ... > "sizeof(int()) => 1" just seems wrong, but maybe it's a matter of taste that has > been explicitly decided. Despite all the proceeding, i don't think "sizeof(int())" should be sizeof ptr to function now. The objective of sizeof is for finding the size an item will be in an array of the items. sizeof(int[3]); => 12 sizeof(int()); => illegal "int()" is a legal type-id for a function, but you can't have an array of functions. "int()" could be decayed to a ptr "int(*)()", but that would be inconsistant with "int[3]" that you wouldn't want to decay. So i conclude that g++ is right by saying "warning: invalid application of ‘sizeof’ to a function type", and gdb should not say "sizeof(int())" => 1