Remove this ad

Lead

Oct 6 13 2:59 PM

Tags : :

While trying to rebuild amule on MacOS 10.8 (current SVN version) after some system upgrades, I noticed the following warning regarding DownloadQueue.cpp, method "CopyFileList":

[code]
warning: operator '?:' has lower precedence than '+'; '+' will be evaluated first [-Wparentheses]
[/code]

This warning is generated by following part of code (see https://code.google.com/p/amule/source/browse/trunk/src/DownloadQueue.cpp#189)

[code]
out_list.reserve(m_filelist.size() + includeCompleted ? m_completedDownloads.size() : 0);
[/code]

where "includeCompleted" is a bool variable.

Maybe the correct code should include parentheses as follows?

[code]
out_list.reserve(m_filelist.size() + (includeCompleted ? m_completedDownloads.size() : 0));
[/code]

Bye,
Mr Hyde
Quote    Reply   
Remove this ad
Remove this ad

#1 [url]

Oct 6 13 3:00 PM

Re: DownloadQueue.cpp and operator '?'

Sorry, I forgot to report the compiler version

[code]
miniwifiz-5.0.5 MrHyde$ g++ --version
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 5.0 (clang-500.2.76) (based on LLVM 3.3svn)
Target: x86_64-apple-darwin12.5.0
Thread model: posix
[/code]

Quote    Reply   

#2 [url]

Oct 6 13 8:03 PM

Re: DownloadQueue.cpp and operator '?'

Yeah, gcc devs like to treat their users like dummies who don't know op precedence. My non-favorite is the warning about && and ||.
The code is correct as it is. I can fix the warning of course, but I'm not set up for compiling at the moment (and superstitious about checking in without compiling).
But thank you for reporting anyway. Did you succeed with building it?

Quote    Reply   

#3 [url]

Oct 6 13 9:55 PM

Re: DownloadQueue.cpp and operator '?'

I just reported the warning because I was not sure about the desired behaviour.

As regards the built in MacOS: I've built with success for arch ppc,i386 with wx 2.8.x on MacOS SnowLeopard but, I don't know why (I'm still investigating), I'm no more able to build for i386,x86_64 with wx 2.9.5 on Mountain Lion.

Or, just to specify, I can build a Mac package, but this crashes immediately once executed.

But don't worry:
- my feeling is that the crash is related to something wrong in my build environment on MacOS 10.8 Mountain Lion (I have suspects about some upgrades of MacPorts, "tool" used to build in MacOS)
- the package built in SnowLeopard works well also in MountainLion
- I was trying to build with wxWidgets 2.9.5 on MountainLion just for my curiosity, but as I said, I can just use the package built in SnowLeopard.

Thanks for your answer,
Mr Hyde

Quote    Reply   

#4 [url]

Oct 7 13 9:23 PM

Re: DownloadQueue.cpp and operator '?'

Meeeeeh.

You and gcc are right and I was wrong. Code should be exactly as you posted.
I apologize to you and the gcc team (though NOT regarding the && || warning).
Impact of the bug is low though. The list doesn't get preallocated as it should and so has to grow dynamically as it is built to do, that's all. I'll fix it of course once I get around to do it. (I'm running Windows 8.1 atm and haven't installed Visual Studio yet.)

Quote    Reply   
Add Reply

Quick Reply

bbcode help