Thread View: gnu.g++.bug
1 messages
1 total messages
Started by Ron Guilmette
Thu, 12 Jan 1989 20:24
Apparent bug in GCC and G++ 1.32 - sizeof(function) == 1
Author: 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);
}
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads