[Patch] Fix undeleted "static QFont *_font" in kglobalsettings.cpp

Olivier Goffart ogoffart at kde.org
Sun Dec 14 17:03:17 GMT 2008


Le mardi 9 décembre 2008, Matthew Woehlke a écrit :
> Johannes Sixt wrote:
> > No, you are misunderstanding: It's not the integers that are stored in an
> > esoteric way, but the *null pointer*! There are architectures out there
> > where the null pointer does not have all bits set to zero. Nevertheless,
> > in the C++ program code you still write
> >
> >    Foo* x = 0;
>
> Eew, trying to think of what you'd have to do to the compiler to support
> this makes my head hurt ;-). Not to mention the gross violation of least
> surprise principle.


I can give you a very concrete example:


#include <iostream>
struct A {
	int a;
	int b;
};
int main() {
	int A::*m = 0;
	int A::*n = &A::a; 
	std::cout << " m = " << *(int*)(&m) << ", n = " << *(int*)(&n) << std::endl;
}

Compiles this program with gcc and the result is:
 m = -1, n = 0

Because the pointer is relative, the 0x000000 binary value points to the first 
member in the class.  So the sementic value 0 or NULL need to be something 
else (hence -1)


Some architecture may have also a relative addressing mechanism for normal 
pointer. (none that we support, ok)

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part.
URL: <http://mail.kde.org/pipermail/kde-core-devel/attachments/20081214/bfe65f53/attachment.sig>


More information about the kde-core-devel mailing list