[vbox-dev] [PATCH 2/8] Fix an implicit conversion from pointer to bool
Jung-uk Kim
jkim at FreeBSD.org
Thu Mar 26 18:59:19 UTC 2015
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256
On 03/26/2015 14:03, Michal Necasek wrote:
>
> The question isn't whether a compiler can warn. The question is,
> why should it?
Although this specific code has absolutely no problem, compilers are
not smart enough to read authors' mind yet. ;-)
> What you quoted doesn't contradict what Frank said. There is a very
> well defined pointer to bool conversion. So what's the problem? Or
> in other words, what is the semantic difference between
The difference is
> if (ptr)
ptr is converted to bool type first
> and
>
> if (ptr != NULL)
ptr is compared to nullptr (if NULL is correctly defined as nullptr).
Basically, the first is a conversion and the second is a comparison.
Jung-uk Kim
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2
iQEcBAEBCAAGBQJVFFcDAAoJEHyflib82/FGGvEIAJCfpg7NhDmUpQ41jLuwmRRJ
TRqA0l+9M79C9VjB1D1eeQeBmbVSlB42VDDwujk3/9g8+2Dpy60XPMSkUUpe1BiJ
e+IiQ00e1xYmVeS4a0H230Rd68fzdGMlZwatzN+B6S2EqdIdO+i4Ui3PgyV65ICP
wcVOCZSF92ZfBbSppVl4mkXcdyRfHPhxMiO8+9MkkJUAy4aPx0jmRZsFWmSnsldH
99zbbcwnb43Vl51KAhzz7MvPCECt030xxMiLAXisx2qgoOgfXDGVKVDgiCEnJN17
1rJWJZ9c2SywKXW6s0mHi/34vFTwjq9mr0OrTgvfXYZ0qEgkqJqnWQVgU56/rd4=
=MIUw
-----END PGP SIGNATURE-----
More information about the vbox-dev
mailing list