This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c/48545] dereferencing does not work as expected


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]