Article View: gnu.g++.bug
Article #1616Apparent bug in GCC and G++ 1.32 - sizeof(function) == 1
From: Ron Guilmette
Date: Thu, 12 Jan 1989 20:24
Date: Thu, 12 Jan 1989 20:24
50 lines
1741 bytes
1741 bytes
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);
}
Technical Details
Message-ID:
<8901122024.AA21962@riunite.aca.mcc.com>Path:
arc1-ca.pugleaf.net!utzoo!telly!ddsw1!lll-winken!killer!mit-eddie!bloom-beacon!tut.cis.ohio-state.edu!MCC.COM!rfgShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!telly!ddsw1!lll-winken!killer!mit-eddie!bloom-beacon!tut.cis.ohio-state.edu!MCC.COM!rfg From: rfg@MCC.COM (Ron Guilmette) Newsgroups: gnu.g++.bug Subject: Apparent bug in GCC and G++ 1.32 - sizeof(function) == 1 Message-ID: <8901122024.AA21962@riunite.aca.mcc.com> Date: 12 Jan 89 20:24:09 GMT Sender: daemon@tut.cis.ohio-state.edu Distribution: gnu Organization: GNUs Not Usenet Lines: 50