A_dict.cc: In member function ‘virtual void A::Streamer(TBuffer&)’:
A_dict.cc:114: warning: dereferencing type-punned pointer will break strict-aliasing rules
compiler -02 options includes -fstrict-aliasing so the definition of streamer:
void A::Streamer(TBuffer &R__b)
{
// Stream an object of class A.
UInt_t R__s, R__c;
if (R__b.IsReading()) {
Version_t R__v = R__b.ReadVersion(&R__s, &R__c); if (R__v) { }
TObject::Streamer(R__b);
R__b >> (Int_t&)typ;
R__b.CheckByteCount(R__s, R__c, A::IsA());
} else {
R__c = R__b.WriteVersion(A::IsA(), kTRUE);
TObject::Streamer(R__b);
R__b << (Int_t)typ;
R__b.SetByteCount(R__c, kTRUE);
}
}
produces this warning because of this line:
R__b >> (Int_t&)typ;
How should I generate _dict file with LinkDef pragma’s to have it properly done ?
I am not interested in solution with -fno-strict-aliasing option given to compiler.
My root version is 5.20.
Thans in advance!
Marcin ALinkDef.h (197 Bytes) A.h (132 Bytes)
The Streamer function, as you have it, is obsolete; instead you should request the new style of streamer function by using in your LinkDef.h:#pragma link C++ class A+;
The dictionary file (C_dict.cc) created by rootcint within both root versions 5.20 and 5.24 has the same part of code:
p = new pair<int,B*>(*(int*) G__Intref(&libp->para[0]), libp->para[1].ref ? *(B**) libp->para[1].ref : *(B**) (&G__Mlong(libp->para[1])));
} else {
p = new((void*) gvp) pair<int,B*>(*(int*) G__Intref(&libp->para[0]), libp->para[1].ref ? *(B**) libp->para[1].ref : *(B**) (&G__Mlong(libp->para[1])));
I do not know what G__Mlong is but dereferencing it breaks strict-aliasing rules… but life is not so simply and that warning is visible with gcc 4.1.2 (debian 3.4.6-5). I tested compilation of the same C_dict.cc with 3.4.6. & 4.3.2 and did not see any warning.
So maybe first check dictionary file created with the newest rootcint and decide if it is real warning or fake for one compilator version.
I cannot reproduce your problem with any ROOT version or compiler version. May be you have some pathological include in your local directory.
Could you replace:
I guess it is not a problem of includes. Tried your modification but without positive result.
In C_dict.cc generated with rootcint I have 2 places in which dereferencing of G__Mlong is applied : (&G__Mlong(libp->para[1]))). In dictionary file included to this post you can try to find them and check if in dictionary files generated by your rootcint they still exist or not.
Please submit your dictionary file created for class C.