Re: [Lcms-user] Build warnings on OSX / clang
An ICC-based CMM for color management
Brought to you by:
mm2
From: Noel C. <NCa...@Pr...> - 2017-08-09 16:08:37
|
For what it's worth I saw both your recent messages, Philip. It's kind of up to Marti whether he wants to tweak that code to make it not emit a warning. Indeed those instructions are mixing unsigned and signed values (e.g., under some runtime conditions the signed cmsS1Fixed14Number values in l1, l2, l3 could be assigned to the unsigned cmsUInt32Number variables ri, gi, bi. Interestingly, Visual Studio's C++ compiler does not flag that as a warning... It's possible it has figured out that the code does not logically allow a signed negative value to be copied to an unsigned lvalue. In any case, for other compilers a change that's valid everywhere using casting to work around this warning would be to code the following: // Now we have to clip to 0..1.0 range ri = (l1 < 0) ? 0 : ((l1 > 16384) ? 16384U : (cmsUInt32Number) l1); gi = (l2 < 0) ? 0 : ((l2 > 16384) ? 16384U : (cmsUInt32Number) l2); bi = (l3 < 0) ? 0 : ((l3 > 16384) ? 16384U : (cmsUInt32Number) l3); An anecdote: On the advice of Bob Friesenhahn who a few days ago suggested building things with multiple compilers to check code, I've been doing that with our in-house products lately... We hadn't thought to take the time to do that before. Specifically, we're rebuilding our Visual Studio C++ projects with clang and the -Wall option, and sure enough it's uncovered several bona fide bugs that had escaped the notice of Visual Studio's compiler alone. I guess they all have some blind spots! Many thanks for the idea, Bob! -Noel |