Warning with gcc 4.1

Hi,
I’m reporting here few warning I have with the new gcc 4.1.2 compiler (from debian Sid) and with root version v5.11.06:

/cern/root/include/Bytes.h: In function ‘void tobuf(char*&, Float_t)’:
/cern/root/include/Bytes.h:222: warning: dereferencing type-punned pointer will break strict-aliasing rules
/cern/root/include/Bytes.h:222: warning: dereferencing type-punned pointer will break strict-aliasing rules
/cern/root/include/Bytes.h:222: warning: dereferencing type-punned pointer will break strict-aliasing rules
/cern/root/include/Bytes.h:222: warning: dereferencing type-punned pointer will break strict-aliasing rules
/cern/root/include/Bytes.h:222: warning: dereferencing type-punned pointer will break strict-aliasing rules
/cern/root/include/Bytes.h:222: warning: dereferencing type-punned pointer will break strict-aliasing rules
/cern/root/include/Bytes.h: In function ‘void tobuf(char*&, Double_t)’:
/cern/root/include/Bytes.h:253: warning: dereferencing type-punned pointer will break strict-aliasing rules
/cern/root/include/Bytes.h: In function ‘Float_t host2net(Float_t)’:
/cern/root/include/Bytes.h:554: warning: dereferencing type-punned pointer will break strict-aliasing rules
/cern/root/include/Bytes.h:554: warning: dereferencing type-punned pointer will break strict-aliasing rules
/cern/root/include/Bytes.h:554: warning: dereferencing type-punned pointer will break strict-aliasing rules
/cern/root/include/Bytes.h:554: warning: dereferencing type-punned pointer will break strict-aliasing rules
/cern/root/include/Bytes.h:554: warning: dereferencing type-punned pointer will break strict-aliasing rules
/cern/root/include/Bytes.h:554: warning: dereferencing type-punned pointer will break strict-aliasing rules
/cern/root/include/Bytes.h: In function ‘Double_t host2net(Double_t)’:
/cern/root/include/Bytes.h:572: warning: dereferencing type-punned pointer will break strict-aliasing rules

Maybe you will find usefull this report for compatibility with the new compiler.

Hi,

this problem has been fixed in the cvs head about one week ago. Can you try and let me know.

Cheers, Fons.

this problem is still present in latest CVS when compiling with -O2

on FC5 AMD MP

g++ (GCC) 4.1.1 20060525 (Red Hat 4.1.1-1)

/mnt/data1/rootdata/root//include/Bytes.h: In function ‘void tobuf(char*&, Float_t)’:
/mnt/data1/rootdata/root//include/Bytes.h:222: warning: dereferencing type-punned pointer will break strict-aliasing rules

base/src/TString.cxx: In member function ‘TString& TString::operator=(const TSubString&)’:
base/src/TString.cxx:410: warning: dereferencing type-punned pointer will break strict-aliasing rules
AND SO ON

Khamit,

Could you try with CVS head as of today afternoon (14h30 Geneva time)?
Fons made one more change in this area.

Rene

cint/src/v6_pcode.cxx: In function ‘int G__asm_optimize3(int*)’:
cint/src/v6_pcode.cxx:6412: warning: dereferencing type-punned pointer will break strict-aliasing rules
cint/src/gcc3strm.cxx: In function ‘int G__G__stream__3_17(G__value*, const char*, G__param*, int)’:
cint/src/gcc3strm.cxx:3023: warning: dereferencing type-punned pointer will break strict-aliasing rules
utils/src/rootcint_tmp.o: In function R__tmpnam()': rootcint_tmp.cxx:(.text+0x6b96): warning: the use oftmpnam’ is dangerous, better use mkstemp' utils/src/rootcint.o: In functionR__tmpnam()’:
rootcint.cxx:(.text+0x6b96): warning: the use of tmpnam' is dangerous, better usemkstemp’
base/src/TStorage.cxx: In static member function ‘static void TStorage::EnableStatistics(int, int)’:
base/src/TStorage.cxx:453: warning: unused variable 'idum’
base/src/TStorage.cxx:453: warning: unused variable 'iidum’
base/src/TString.cxx: In static member function ‘static TStringRef* TStringRef::GetRep(Ssiz_t, Ssiz_t)’:
base/src/TString.cxx:117: warning: dereferencing type-punned pointer will break strict-aliasing rules
base/src/TString.cxx:118: warning: dereferencing type-punned pointer will break strict-aliasing rules
base/src/TString.cxx: In constructor ‘TString::TString()’:
base/src/TString.cxx:269: warning: dereferencing type-punned pointer will break strict-aliasing rules
base/src/TString.cxx:270: warning: dereferencing type-punned pointer will break strict-aliasing rules
base/src/TString.cxx: In member function ‘TString& TString::operator=(char)’:
base/src/TString.cxx:356: warning: dereferencing type-punned pointer will break strict-aliasing rules
base/src/TString.cxx:357: warning: dereferencing type-punned pointer will break strict-aliasing rules
base/src/TString.cxx: In member function ‘TString& TString::operator=(const char*)’:
base/src/TString.cxx:370: warning: dereferencing type-punned pointer will break strict-aliasing rules
base/src/TString.cxx:371: warning: dereferencing type-punned pointer will break strict-aliasing rules
base/src/TString.cxx: In member function ‘TString& TString::operator=(const std::string&)’:
base/src/TString.cxx:384: warning: dereferencing type-punned pointer will break strict-aliasing rules
base/src/TString.cxx:385: warning: dereferencing type-punned pointer will break strict-aliasing rules
base/src/TString.cxx: In member function ‘TString& TString::operator=(const TSubString&)’:
base/src/TString.cxx:410: warning: dereferencing type-punned pointer will break strict-aliasing rules
base/src/TString.cxx:411: warning: dereferencing type-punned pointer will break strict-aliasing rules
base/src/TString.cxx: In member function ‘TString& TString::Remove(TString::EStripType, char)’:
base/src/TString.cxx:685: warning: dereferencing type-punned pointer will break strict-aliasing rules
base/src/TString.cxx:686: warning: dereferencing type-punned pointer will break strict-aliasing rules
meta/src/TClass.cxx: In member function ‘Int_t TClass::ReadBuffer(TBuffer&, void*, Int_t, UInt_t, UInt_t)’:
meta/src/TClass.cxx:3783: warning: dereferencing type-punned pointer will break strict-aliasing rules
meta/src/TClass.cxx: In member function ‘Int_t TClass::ReadBuffer(TBuffer&, void*)’:
meta/src/TClass.cxx:3827: warning: dereferencing type-punned pointer will break strict-aliasing rules
meta/src/TClass.cxx: In member function ‘Int_t TClass::WriteBuffer(TBuffer&, void*, const char*)’:
meta/src/TClass.cxx:3868: warning: dereferencing type-punned pointer will break strict-aliasing rules
meta/src/TClass.cxx: In member function ‘void TClass::Streamer(void*, TBuffer&)’:
meta/src/TClass.cxx:3911: warning: dereferencing type-punned pointer will break strict-aliasing rules
meta/src/TClass.cxx:3916: warning: dereferencing type-punned pointer will break strict-aliasing rules
net/src/TMessage.cxx: In member function ‘Int_t TMessage::Uncompress()’:
net/src/TMessage.cxx:284: warning: dereferencing type-punned pointer will break strict-aliasing rules
auth/src/TAuthenticate.cxx: In static member function ‘static Int_t TAuthenticate::SendRSAPublicKey(TSocket*, Int_t)’:
auth/src/TAuthenticate.cxx:4048: warning: dereferencing type-punned pointer will break strict-aliasing rules
hist/src/TProfile2D.cxx: In member function ‘virtual void TProfile2D::Streamer(TBuffer&)’:
hist/src/TProfile2D.cxx:1786: warning: dereferencing type-punned pointer will break strict-aliasing rules
hist/src/TProfile.cxx: In member function ‘virtual void TProfile::Streamer(TBuffer&)’:
hist/src/TProfile.cxx:1837: warning: dereferencing type-punned pointer will break strict-aliasing rules
/home/ardashev/root/freetype/src/freetype-2.1.9/src/bdf/bdfdrivr.c: In function ‘BDF_Face_Init’:
/home/ardashev/root/freetype/src/freetype-2.1.9/src/bdf/bdfdrivr.c:334: warning: ‘font’ may be used uninitialized in this function
In file included from /home/ardashev/root/freetype/src/freetype-2.1.9/src/sfnt/sfnt.c:25:
/home/ardashev/root/freetype/src/freetype-2.1.9/src/sfnt/sfdriver.c: In function ‘sfnt_get_interface’:
/home/ardashev/root/freetype/src/freetype-2.1.9/src/sfnt/sfdriver.c:301: warning: ISO C forbids conversion of function pointer to object pointer type
/home/ardashev/root/freetype/src/freetype-2.1.9/src/sfnt/sfdriver.c:304: warning: ISO C forbids conversion of function pointer to object pointer type

x3d/src/x3d.c: In function ‘DrawLogo’:
x3d/src/x3d.c:395: warning: dereferencing type-punned pointer will break strict-aliasing rules
x3d/src/x3d.c:403: warning: dereferencing type-punned pointer will break strict-aliasing rules
x3d/src/x3d.c:413: warning: dereferencing type-punned pointer will break strict-aliasing rules
x3d/src/x3d.c:421: warning: dereferencing type-punned pointer will break strict-aliasing rules
x3d/src/x3d.c:429: warning: dereferencing type-punned pointer will break strict-aliasing rules
x3d/src/x3d.c:437: warning: dereferencing type-punned pointer will break strict-aliasing rules
x3d/src/x3d.c:445: warning: dereferencing type-punned pointer will break strict-aliasing rules
x3d/src/x3d.c:455: warning: dereferencing type-punned pointer will break strict-aliasing rules
x3d/src/x3d.c:463: warning: dereferencing type-punned pointer will break strict-aliasing rules
x3d/src/x3d.c:471: warning: dereferencing type-punned pointer will break strict-aliasing rules
x3d/src/x3d.c:479: warning: dereferencing type-punned pointer will break strict-aliasing rules
x3d/src/x3d.c: In function ‘DrawHiddenLines’:
x3d/src/x3d.c:2567: warning: dereferencing type-punned pointer will break strict-aliasing rules
x3d/src/x3d.c:2571: warning: dereferencing type-punned pointer will break strict-aliasing rules
x3d/src/x3d.c:2600: warning: dereferencing type-punned pointer will break strict-aliasing rules
x3d/src/x3d.c:2604: warning: dereferencing type-punned pointer will break strict-aliasing rules
x3d/src/x3d.c:2626: warning: dereferencing type-punned pointer will break strict-aliasing rules
x3d/src/x3d.c:2630: warning: dereferencing type-punned pointer will break strict-aliasing rules
x3d/src/x3d.c:2657: warning: dereferencing type-punned pointer will break strict-aliasing rules
x3d/src/x3d.c:2662: warning: dereferencing type-punned pointer will break strict-aliasing rules
x3d/src/x3d.c: In function ‘DrawPolys’:
x3d/src/x3d.c:2722: warning: dereferencing type-punned pointer will break strict-aliasing rules
x3d/src/x3d.c:2755: warning: dereferencing type-punned pointer will break strict-aliasing rules
x3d/src/x3d.c:2780: warning: dereferencing type-punned pointer will break strict-aliasing rules
x3d/src/x3d.c:2811: warning: dereferencing type-punned pointer will break strict-aliasing rules
asimage/src/TASImage.cxx: In member function ‘virtual void TASImage::WriteImage(const char*, TImage::EImageFileTypes)’:
asimage/src/TASImage.cxx:453: warning: dereferencing type-punned pointer will break strict-aliasing rules
asimage/src/TASImage.cxx: In member function ‘void TASImage::CreateThumbnail()’:
asimage/src/TASImage.cxx:5259: warning: dereferencing type-punned pointer will break strict-aliasing rules
pyroot/src/Converters.cxx: In member function ‘virtual Bool_t PyROOT::TVoidPtrRefConverter::SetArg(PyObject*, G__CallFunc*)’:
pyroot/src/Converters.cxx:788: warning: dereferencing type-punned pointer will break strict-aliasing rules
pyroot/src/ObjectProxy.cxx: In function ‘PyObject* PyROOT::::op_richcompare(PyROOT::ObjectProxy*, PyROOT::ObjectProxy*, int)’:
pyroot/src/ObjectProxy.cxx:69: warning: dereferencing type-punned pointer will break strict-aliasing rules
pyroot/src/ObjectProxy.cxx:70: warning: dereferencing type-punned pointer will break strict-aliasing rules
pyroot/src/ObjectProxy.cxx:73: warning: dereferencing type-punned pointer will break strict-aliasing rules
pyroot/src/RootModule.cxx: In function ‘PyObject*::AddressOf(PyObject*, PyObject*)’:
pyroot/src/RootModule.cxx:233: warning: dereferencing type-punned pointer will break strict-aliasing rules
pyroot/src/RootModule.cxx: In function ‘PyObject*::SetOwnership(PyObject*, PyObject*)’:
pyroot/src/RootModule.cxx:319: warning: dereferencing type-punned pointer will break strict-aliasing rules
pyroot/src/RootWrapper.cxx: In function ‘PyObject*::CreateNewROOTPythonClass(const std::string&, PyObject*)’:
pyroot/src/RootWrapper.cxx:58: warning: dereferencing type-punned pointer will break strict-aliasing rules
pyroot/src/RootWrapper.cxx: In function ‘PyObject* PyROOT::BuildRootClassBases(TClass*)’:
pyroot/src/RootWrapper.cxx:333: warning: dereferencing type-punned pointer will break strict-aliasing rules
pyroot/src/RootWrapper.cxx: In function ‘PyObject* PyROOT::BindRootObject(void*, TClass*, Bool_t)’:
pyroot/src/RootWrapper.cxx:670: warning: dereferencing type-punned pointer will break strict-aliasing rules
pyroot/src/TPyClassGenerator.cxx: In function ‘int::PyMemFuncCallback(G__value*, const char*, G__param*, int)’:
pyroot/src/TPyClassGenerator.cxx:87: warning: dereferencing type-punned pointer will break strict-aliasing rules
hbook/src/THbookFile.cxx: In member function ‘virtual void THbookFile::SetBranchAddress(Int_t, const char*, void*)’:
hbook/src/THbookFile.cxx:574: warning: dereferencing type-punned pointer will break strict-aliasing rules
proofd/src/XrdProofConn.cxx: In member function ‘bool XrdProofConn::Login()’:
proofd/src/XrdProofConn.cxx:906: warning: dereferencing type-punned pointer will break strict-aliasing rules
proofd/src/XrdProofConn.cxx: In member function ‘XrdSecProtocol* XrdProofConn::Authenticate(char*, int)’:
proofd/src/XrdProofConn.cxx:1120: warning: dereferencing type-punned pointer will break strict-aliasing rules
proofx/src/TXSocket.cxx: In member function ‘Bool_t TXSocket::Create()’:
proofx/src/TXSocket.cxx:831: warning: dereferencing type-punned pointer will break strict-aliasing rules
proofx/src/TXSocket.cxx: In member function ‘Bool_t TXSocket::Ping(Bool_t)’:
proofx/src/TXSocket.cxx:976: warning: dereferencing type-punned pointer will break strict-aliasing rules
proofx/src/TXSocket.cxx: In member function ‘TObjString* TXSocket::SendCoordinator(Int_t, const char*)’:
proofx/src/TXSocket.cxx:1364: warning: dereferencing type-punned pointer will break strict-aliasing rules
proofx/src/TXSocket.cxx:1377: warning: dereferencing type-punned pointer will break strict-aliasing rules
proofx/src/TXSocket.cxx:1382: warning: dereferencing type-punned pointer will break strict-aliasing rules
rpdutils/src/net.cxx: In function ‘int ROOT::NetRecv(char*, int, EMessageTypes&)’:
rpdutils/src/net.cxx:305: warning: dereferencing type-punned pointer will break strict-aliasing rules

Hi,

for the time being I fixed Bytes.h so that users including ROOT headers don’t get warnings. The remaining warnings will be fixed soon and only appear when compiling ROOT itself (i.e. they are in .cxx files).

Cheers, Fons.