From kde-devel Thu Oct 28 20:31:19 2004 From: Thiago Macieira Date: Thu, 28 Oct 2004 20:31:19 +0000 To: kde-devel Subject: Re: Comparing pointers via cast to int? Message-Id: <200410281731.19377.thiago.macieira () kdemail ! net> X-MARC-Message: https://marc.info/?l=kde-devel&m=109899564310891 MIME-Version: 1 Content-Type: multipart/mixed; boundary="--===============0402020818==" --===============0402020818== Content-Type: multipart/signed; boundary="nextPart3803605.8RXzST3BXS"; protocol="application/pgp-signature"; micalg=pgp-sha1 Content-Transfer-Encoding: 7bit --nextPart3803605.8RXzST3BXS Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Adriaan de Groot wrote: >Now, senderFrame and viewFrame are both QObject *, and what's worse is > that an int isn't necessarily big enough to hold those pointers.=20 Agreed. That's a bug on 64-bit platforms. > Would either of > > if ( senderFrame && viewFrame && viewFrame !=3D senderFrame ) > > if ( senderFrame && viewFrame && > (void *)viewFrame !=3D (void *)senderFrame ) The first one is better. If that generates a warning, cast one of the pointers to the other one's=20 type, using static_cast. Also note that two pointers of different types may differ and yet point to= =20 the same object! The original comparison is more than flawed. =2D-=20 Thiago Macieira - Registered Linux user #65028 thiago (AT) macieira (DOT) info ICQ UIN: 1967141 PGP/GPG: 0x6EF45358; fingerprint: E067 918B B660 DBD1 105C 966C 33F5 F005 6EF4 5358 --nextPart3803605.8RXzST3BXS Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.6 (GNU/Linux) iD8DBQBBgVcXM/XwBW70U1gRAq/vAJ0Xj6q/lc00m9bm4jEoKyL68StWKwCffFkp 0iGXc/DkfuNgbQ7c/zG8F84= =Z/CH -----END PGP SIGNATURE----- --nextPart3803605.8RXzST3BXS-- --===============0402020818== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline >> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe << --===============0402020818==--