Board index » cppbuilder » BCB2006: -Oi (Intrinsic optimization) fails with strcmp()

BCB2006: -Oi (Intrinsic optimization) fails with strcmp()


2005-12-22 03:03:43 AM
cppbuilder22
If I use -Oi (which is automatically activated by -O2) the strcmp()
function fails with
Error E2015 - Ambigiousity between
'cdecl __strcmp__(const char *,const char *)' and 'cdecl
std::__strcmp__(const char *,const char *
)' in function int mystrcmp(const char *str1, const char *str2)
int mystrcmp(const char *str1, const char *str2)
{
return (str1 && str2) ? strcmp(str1, str2) : (str1 ? 1 : (str2 ? -1 :
0));
}
But if I use -O1 or no optimization at all (debug mode) the file compiles
without errors.
I have already seen that in Debug mode (no optimization) the PCH creation
works but in Release mode (optimizations active) it always aborts PCH
creation with "Code in header" that is found in _str.h. And guess what
function: strcmp().
I'll see if I can create a reduces to the minimum testcase.
--
Regards,
Andreas Hausladen
 
 

Re:BCB2006: -Oi (Intrinsic optimization) fails with strcmp()

Andreas Hausladen wrote:
Quote
If I use -Oi (which is automatically activated by -O2) the strcmp()
function fails with

Error E2015 - Ambigiousity between
'cdecl __strcmp__(const char *,const char *)' and 'cdecl
std::__strcmp__(const char *,const char *
)' in function int mystrcmp(const char *str1, const char *str2)


int mystrcmp(const char *str1, const char *str2)
{
return (str1 && str2) ? strcmp(str1, str2) : (str1 ? 1 : (str2 ? -1 :
0));
}

But if I use -O1 or no optimization at all (debug mode) the file compiles
without errors.
You could try either std::strcmp or ::strcmp to diambiguate them.
 

Re:BCB2006: -Oi (Intrinsic optimization) fails with strcmp()

Edward Diener wrote:
Quote
You could try either std::strcmp or ::strcmp to diambiguate them
But without -O2 / -Oi the code compiles. So there is something strange
going on when instrinsics optimization is active.
--
Regards,
Andreas Hausladen
 

{smallsort}

Re:BCB2006: -Oi (Intrinsic optimization) fails with strcmp()

Andreas Hausladen wrote:
Quote
Edward Diener wrote:


>You could try either std::strcmp or ::strcmp to diambiguate them


But without -O2 / -Oi the code compiles. So there is something strange
going on when instrinsics optimization is active.
If you are lucky it might be fixed after another four years, but then
again don't count on it. Take a look at all the compiler bugs which were
reported and easily demonstratable for BCB5/BCB6 many years ago, and
were evidently, if one is to believe QC, never fixed for C++ Builder
2006, and you will get the idea about the importance Borland gives to
their own C++ compiler.
 

Re:BCB2006: -Oi (Intrinsic optimization) fails with strcmp()

Quote
...If you are lucky it might be fixed after another four years...
Oh really? Just what is it that is broken?
. Ed
Quote
Edward Diener wrote in message
news:43a9d7e0$ XXXX@XXXXX.COM ...
 

Re:BCB2006: -Oi (Intrinsic optimization) fails with strcmp()

Edward Diener wrote:
Quote
If you are lucky it might be fixed after another four years, but then
again don't count on it.
This bug was not present in bcc32 5.5.x, bcc32 5.6.4. And it looks like a
Standard C Library problem.
--
Regards,
Andreas Hausladen