ICU-23357 measunit_extra.cpp: Fix error: 'abs' ambiguous#3916
ICU-23357 measunit_extra.cpp: Fix error: 'abs' ambiguous#3916Dave-Allured wants to merge 6 commits into
Conversation
|
@Dave-Allured could you please create a Jira ticket for this issue? https://icu.unicode.org/bugs @eggrobin or @roubert could you please take a look at the math & standard library calls here? (very small change...) |
|
|
My change is now rewritten to use the modf() function correctly. Here is a revised overall summary of this PR.
In my opinion, the standard function is a slightly more robust method than the previous "handcrafted" fractional test. However, I readily admit that the previous method performed well, and did not seem to have any numerical flaws. The irony is that my entire motivation for this change is simply compatibility with a few older compilers. This now seems like a lot of trouble to fix those older compiles. At least I can say that this avoids the original mixed-type expression (double minus uint64_t), and the mysterious "ambiguous" error, which I never did understand where that was coming from. |
roubert
left a comment
There was a problem hiding this comment.
OK, now the header file and function call are correct and all tests on the CI pass.
|
@roubert Thank you. Note to admin: I am not able to use the git command line because of an authentication problem. Therefore I am using github only.for PR's. Github does not currently provide a squash function. Therefore I must request that you use squash-merge when merging this. Thanks again for your assistance. |
|
The original error message in the issue is unsettling, as it is suggesting that The fix should be as simple as just including |
|
@eggrobin Thank you for your assessment and deeper analysis of my original problem. Missing header, now I see that. Let us make a final choice. You said "no need to change". However, as I said, I think that the purpose-built modf function is slightly preferable to the original "handcrafted" method to split integral and fractional parts. Do you think this is sufficient to justify my proposed code change? |
Yes. |
|
Now I suspect there may be some corner cases where legitimate integer input strings are falsely rejected by this test. I am converting this to Draft until I can finish checking. |
measunit_extra.cpp, lines 687-689:
This code is used to check an input string for a non-integer value.
With some older compilers, this generates "error: call to 'abs' is ambiguous".
This PR will avoid the "abs" error by replacing the handcrafted fractional test, with appropriate use of "modf".
I am not experienced with C++. Someone please check this work, thank you.
Downstream issue with complete build log: https://trac.macports.org/ticket/73705
Platform was: macOS 10.14.6 (darwin/18.7.0) arch i386
Compiler was: Apple LLVM version 10.0.1 (clang-1001.0.46.4)
Dialect flag was: -std=gnu++11
TODO: Please read the following on ICU Contributing, and then delete these instructions.
-- Did not read. If this PR is not tolerable, let me know and I will fix.
-- Did not read.
Checklist