[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: [OT] errors with g++-4.5 not with g++-4.4



Hi Hugo,
On Sat, Mar 12, 2011 at 03:35:55PM -0600, Hugo Vanwoerkom wrote:
> Axel Freyn wrote:
>> Hi Hugo,
>> On Sat, Mar 12, 2011 at 11:17:19AM -0600, Hugo Vanwoerkom wrote:
>>> Hi,
>>>
>>> I am looking for your opinion as to whose bug this is.
>>>
>>> I have a C++ project ( http://gpc-qt.sourceforge.net/ ) that consists 
>>> of  more than 103 C++ sourcefiles (1000's of lines of code) that get 
>>> copiled  into a single executable.
>>>
>>> Suddenly using the g++-4.5 compiler it produces an error in the link phase:
>>>
>>> ...
>>> grafrs.cpp:(.text+0x355d): undefined reference to `mutrec'
>>> ...
>>>
>>> But when I use the g++-4.4 compiler everything compiles and links   
>>> without error, like it has for years with previous C++ compilers.
>>>
>>> Do I file a bug with the g++-4.5 package?
>>
>> I would first assume an error in this project -- and not in g++-4.5 :-)
>>
>> However, before writing a bug, it would be very usefull if you succeed
>> to reduce the test case: I'm almost sure that none of the g++-developers
>> will be happy with a bug report stating "somehow those 1000's lines of
>> code don't compile correctly" -- I would expect a much faster help if
>> you could reduce the problem and reduce it to a few hundred (or even a
>> few tenth) of lines of code...
>> Is that possible?
>>
>> I just had a VERY quick look at the code: It seems that "mutrec" is
>> defined in "aa.cpp". Do you link aa.cpp and grafrs.cpp together?
>>
>
> Thanks Axel. It is stranger yet:
> 1. mutrec is defined in aa.cpp
> 2. It is used as extern in mc.cpp, grafrs.cpp and setfile.cpp
> 3. But g++-4.5 only finds undefined referenes in mc.cpp and grafrs.cpp,  
> *not* in setfile.cpp
> 4. Yet the extern for mutrec is defined in all three the same way.
> 5. And previous compilers have found no errors.
> 6. The whole bunch is linked together via aa.pro that is used in  
> 'qmake-qt4 -o Makefile aa.pro' to create a makefile for make.
Some updates from my checks:
a) I can't compile the code on amd64: in tranrs.cpp, lines 1789 and 1810
you convert "double *" to "int".  However, on amd64 "double *" is of
size 8 bytes, "int" is only 4 bytes ==> You loose precision and get
quite unpredictable results. In addition, g++ from squeeze and wheezy
(4.4 and 4.5) do NOT compile it. Chaning "int" to "long", it works
correctly (maybe the "correct" type would be std::ptrdiff_t?)

b) The linker error: There is a difference between mc.cpp grafrs.cpp AND
setfile.cpp:
 - setfile: you have "extern mutrc" OUTSIDE of all functions
 - mc and grafrs: the extern mutrc appears IN a function (drwts and
   weights)
Maybe that's the critical point?

Axel


Reply to: