This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/48545] dereferencing does not work as expected
- From: "d.g.gorbachev at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Mon, 11 Apr 2011 18:45:54 +0000
- Subject: [Bug c/48545] dereferencing does not work as expected
- Auto-submitted: auto-generated
- References: <bug-48545-4@http.gcc.gnu.org/bugzilla/>
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48545
--- Comment #4 from Dmitry Gorbachev <d.g.gorbachev at gmail dot com> 2011-04-11 18:45:50 UTC ---
*output and output have different types, but numberically they are equal.
That's how C works.
More fun:
extern int printf(const char *, ...);
char str[4] = "abc";
int main(void)
{
int (*f)(const char *, ...) = &printf;
int (*g)(const char *, ...) = printf;
char (*p)[4] = &str;
char *q = str;
(*f)("%p %p %p %p %p %p\n", &printf, printf, f, *f, g, *g);
f("%p %p %p %p %p %c\n", &str, str, p, *p, q, *q);
return 0;
}
It prints:
0x80482d8 0x80482d8 0x80482d8 0x80482d8 0x80482d8 0x80482d8
0x8049624 0x8049624 0x8049624 0x8049624 0x8049624 a