rfg@MCC.COM (Ron Guilmette) (01/13/89)
I believe that putting an ampersand in front of a function name is normally superfluous and that the same meanning is implied even without the ampersand. Therefore, it seems that for any function "f", it should be the case that: sizeof (f) == sizeof (&f) The following program demonstrates that this is not the case for GCC 1.32 and G++ 1.32. Rather, it seems that sizeof (f) yields 1. Is this called for by some part of ANSI C that I don't know about? links: md == m68k.md aux-output.c == output-m68k.c config.h == xm-m68k.h tm.h == tm-sun3.h (or tm-sun3+.h for G++) /* --------------------------- cut here ----------------------------------*/ /* Description - Check that the sizeof() function yields proper values. */ int _failed = 0; void _result (void); void _cmp_eq (char *, unsigned int, unsigned int); int main() { _cmp_eq ("sizeof (main) != sizeof (char *)", sizeof (main), sizeof (char *)); _cmp_eq ("sizeof (main) != sizeof (&main)", sizeof (main), sizeof (&main)); _result (); } void _cmp_eq (char *msg, unsigned int v1, unsigned int v2) { if (v1 != v2) { printf ("FAILED - %s: %d\n", msg, v1); _failed = 1; } } void _result () { if (!_failed) printf ("PASSED"); exit (0); }