Home » Developing U++ » U++ Developers corner » AString::Compare missing explicit return value (q will = 0 if the loop isn't broken. This value should be returned explicitly.)
AString::Compare missing explicit return value [message #44081] |
Tue, 23 December 2014 10:56 |
rainbowsally
Messages: 29 Registered: December 2014
|
Promising Member |
|
|
For x86-based C/C++, the eax/rax register is usually returned by default (for int types) and this is probably the register holding 'q' below, but it can't be counted on.
File: uppsrc/Core/AString.hpp
template <class B>
int AString<B>::Compare(const tchar *b) const
{
const tchar *a = B::Begin();
const tchar *ae = End();
for(;;) {
if(a >= ae)
return *b == 0 ? 0 : -1;
if(*b == 0)
return 1;
int q = cmpval__(*a++) - cmpval__(*b++);
if(q)
return q;
}
// -rs added 1 line to explicitly return q(=0)
return 0;
}
|
|
|
Goto Forum:
Current Time: Sat Apr 27 15:04:19 CEST 2024
Total time taken to generate the page: 0.08008 seconds
|