Message-ID: <3AE2C625.9C560766@earthlink.net> From: Martin Ambuhl X-Mailer: Mozilla 4.76 [en] (Win95; U) X-Accept-Language: en,zh-CN,fr,de-CH,ru MIME-Version: 1.0 Newsgroups: comp.os.msdos.djgpp Subject: Re: Printing function pointers References: <3AE082F7 DOT B4E9C05 AT jps DOT net> <3AE1D9D3 DOT AC592F3F AT mail DOT rosecom DOT ca> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Lines: 40 Date: Sat, 21 Apr 2001 23:52:24 GMT NNTP-Posting-Host: 209.246.89.22 X-Complaints-To: abuse AT earthlink DOT net X-Trace: newsread2.prod.itd.earthlink.net 987897144 209.246.89.22 (Sat, 21 Apr 2001 16:52:24 PDT) NNTP-Posting-Date: Sat, 21 Apr 2001 16:52:24 PDT Organization: EarthLink Inc. -- http://www.EarthLink.net X-Received-Date: Sat, 21 Apr 2001 16:51:02 PDT (newsmaster1.prod.itd.earthlink.net) To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com April wrote: > > I changed your example to include explicit type casts: Please note that this whole thread pertains to something that has no meaning in standard C++. Had you attempted to cast with the modern static_cast<> mechanism, you would have gotten a diagnostic from gcc. This would be true even if the cast were to `void *', since the standard does not guarantee that function pointers can be converted to object pointers. If you are willing to use reinterpret_cast<>, gcc will let you, but this particular construct is almost always a sign that you are going where you ought not to go. > > #include > > int junk1() { return 111; } > > int junk2() { return 222; } > > int main() > { > if ( junk1 != junk2 ) { > cout << "different\n"; > } > cout << ( unsigned long )junk1 << '\n'; > cout << ( unsigned long )junk2 << '\n'; > return 0; > } > > and I got: > > different > 5488 > 5508 > > I don't know enough about the C++ standard to explain why though