The error given:
..\..\..\..\trunk\lib\Transforms\Scalar\LoopStrengthReduce.cpp(1016) :
error C2668: 'abs' : ambiguous call to overloaded function
f:\Program Files\Microsoft Visual Studio
8\VC\include\math.h(539): could be 'long double abs(long double)'
f:\Program Files\Microsoft Visual Studio
8\VC\include\math.h(491): or 'float abs(float)'
f:\Program Files\Microsoft Visual Studio
8\VC\include\math.h(487): or 'double abs(double)'
f:\Program Files\Microsoft Visual Studio
8\VC\include\math.h(485): or 'long abs(long)'
f:\Program Files\Microsoft Visual Studio
8\VC\include\stdlib.h(415): or 'int abs(int)'
while trying to match the argument list '(int64_t)'
It should be rather obvious from the message. The error is in
LoopStrengthReduce.cpp on line 1016:
(unsigned(abs(SInt)) < SSInt || (SInt % SSInt) != 0))
From looking at the code and what it looks like it should be doing, I
cannot really tell whether it should use the 32-bit override, or if it
should use something like the long double override, considering this
is a 64-bit integer.
Either way, will not compile until a specific type override is given
of the form (just an example, I do not know if the 32-bit version is
what is wanted here):
(unsigned(abs((int)SInt)) < SSInt || (SInt % SSInt) != 0))
The error given:
..\..\..\..\trunk\lib\Transforms\Scalar\LoopStrengthReduce.cpp(1016) :
error C2668: 'abs' : ambiguous call to overloaded function
It should be rather obvious from the message. The error is in
LoopStrengthReduce.cpp on line 1016:
(unsigned(abs(SInt)) < SSInt || (SInt % SSInt) != 0))
From looking at the code and what it looks like it should be doing, I
cannot really tell whether it should use the 32-bit override, or if it
should use something like the long double override, considering this
is a 64-bit integer.
It should be a 64-bit integer abs, although gcc seems to be generating code for 32-bit integer (which, in this code, would give the expected answer in any reasonable example). There are 4 occurrences of this usage in that file (with 3 different authors) so I think we need to write one; apparently nobody realized there wasn't one in the standard libraries (I didn't either).
Ah, I mentioned it before, but was told that the error was not
appearing with GCC and they were busy at the time, so I just have been
inserting an (int) in my version ever since, but it reappeared when I
synced back to trunk today since I deleted my version, and I have just
been reporting random things I have been crossing. I noticed a few
other warnings about struct/class forward declarations as well, but
did not catch them in time, I intend to look through it closely later
and report more.
So, for now, just keep using (int) in my version until it is fixed in trunk?
Also, IndVarSimplify.cpp has the same problem, only one abs usage in
it, line 700:
if (Max.getZExtValue() > static_cast<uint64_t>(abs(intEV - intIV)))
Following your style change:
if (Max.getZExtValue() > static_cast<uint64_t>(abs64(intEV - intIV)))
Also, why make an abs64, why not just override abs with 64 bit parameters?
The error given:
..\..\..\..\trunk\lib\Transforms\Scalar
\LoopStrengthReduce.cpp(1016) :
error C2668: 'abs' : ambiguous call to overloaded function
I checked in a fix.
Also, IndVarSimplify.cpp has the same problem, only one abs usage in
it, line 700:
if (Max.getZExtValue() > static_cast<uint64_t>(abs(intEV - intIV)))
Following your style change:
if (Max.getZExtValue() > static_cast<uint64_t>(abs64(intEV - intIV)))
Fixed, thanks.
Also, why make an abs64, why not just override abs with 64 bit parameters?
Because I think overloading standard functions is evil. ymmv.
And yet operators >> amd << are great examples of overriding for ostream. 