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

Thiago Macieira thiago at kde.org
Sun Dec 14 18:11:59 GMT 2008


Olivier Goffart wrote:
>#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)

Pointer to members usually cause this kind of problem. You have to be very 
careful, since the sizeof may not be the size of a pointer. See:

$ cat > file.cpp
class A { void f(); };
int main() { typedef void (A::* pmf)(); return sizeof(pmf); }

$ g++ -o file file.cpp
$ ./file; echo $?
8

This was on a 32-bit architecture.

-- 
  Thiago Macieira  -  thiago (AT) macieira.info - thiago (AT) kde.org
    PGP/GPG: 0x6EF45358; fingerprint:
    E067 918B B660 DBD1 105C  966C 33F5 F005 6EF4 5358
-------------- 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/ebff5a28/attachment.sig>


More information about the kde-core-devel mailing list