Board index » cppbuilder » A compilier bug with strcmp?

A compilier bug with strcmp?

In BCB5, when I change "code optimizations" to "speed" the compilier
gives an error on the following assignment statement:

int (*cmpPtr)(const char*, const char*) ;      // a pointer to
strcmp or stricmp

void foo (...)
{
cmpPtr = stricmp ;     // this assignment is OK

.....<snip>....

cmpPtr = strcmp ;   // this assignment gives an error!

Quote
}

The error message is:

E2027 Must take address of a memory location Compiler error

Your source file used the address-of operator (&) with an expression
that can't be used that way; for example, a register variable.
----------------------

Is this a bug in the compilier? I can work around it by turning off
certain optimizations, but I thought Borland might want to know
about this.
Eric

 

Re:A compilier bug with strcmp?


Quote
> In BCB5, when I change "code optimizations" to "speed" the compilier
> gives an error on the following assignment statement:

The compiler is inserting an intrinsic for the function (-Oi). If you really
need this to work you can #undef strcmp and re-prototype the function.

--
Anduin Withers

Re:A compilier bug with strcmp?


Quote
In article <3b569d51$1_1@dnews>, Anduin Withers <awith...@anduin.com> wrote:
>The compiler is inserting an intrinsic for the function (-Oi). If you really
>need this to work you can #undef strcmp and re-prototype the function.

I believe that this is recommended procedure anyway, no matter what
compiler/optimization levels you are using.  I seem to remember that the
Gnu C Compiler has similar issues at times.  Though you should not have to
prototype the function.

Review of comp.lang.c and you will often see something like "Any standard
library function may also be defined as a macro."  A search on
groups.google.com on "comp.lang.c #undef standard macro function" can
provide some interesting reading.

mrc
--
     Mike Castle      dalg...@ix.netcom.com      www.netcom.com/~dalgoda/
    We are all of us living in the shadow of Manhattan.  -- Watchmen
fatal ("You are in a maze of twisty compiler features, all different"); -- gcc

Re:A compilier bug with strcmp?


Quote
> Though you should not have to prototype the function.

Perhaps true for other compilers. However at least for Borland's BCB strcmp
doesn't really exist with -Oi.

--
Anduin Withers

Other Threads