Board index » cppbuilder » very strange

very strange

Here is a strange problem I ran into today.  At least it is Friday so I
can go home and ponder it over the weekend but here it is.

I began having problems with an application and in debugging it I
realized that the problems were caused by  a particular pointer that was
incorrect when passed into a function. In trying to get to the bottom of
it,  I created a little do-nothing test function to see what was
happening and why.

This is the declaration of the test function:

( IFIL is a typedefed structure that I have used forever and that has
not been recently changed )

static void test(IFIL * ifil, IFIL * Ifil);  // note the only difference
in the two parameters is the capitalization

I call the function like this:

IFIL core;

test( &core, &core);

Here is the function itself:

test(IFIL * ifil, IFIL * Ifil)
{

    IFIL * foo;

    foo = ifil;  // this foo is not correct

    foo = Ifil; // this foo points to core

Quote
}

The first prameter (ifil) is not interpreted correctly in the test
function  so the assignment to foo is incorrect.  The second parameter
is fine and assigns the address of core to foo.  The call stack shows
test( ifil=:005D896C, Ifil=:005D896C) so it seems to have been put on
the stack correctly.

When I evaluate the first parameter "ifil", it shows this:
ifil: ifil: 008CF81C

When I evaluate the second parameter "Ifil", it shows this:
Ifil: ifil *: 008CF820::005D896C

If I try to evaluate the expression "foo = ifil" I get this error:

E2034 Cannot convert 'ifil' to 'ifil *'

This program worked ok until today. I cannot figure out what is wrong.
It is doing weird things, but only if I use the name "ifil" for the
parameter - anything else works fine.  It is as if the compiler is
having problems distinguishing case or something. The name "ifil" is not
used anywhere in any of my header files and I cannot declare any "ifil"
variables.    I have completely rebuilt the program.  I have not
recently changed any options that I know of.  Any help with this would
be greatly appreciated.

Steve Contris

 

Re:very strange


Quite probably between the assignment and the end of the function the value
of the variable foo is never used so the compiler never tried to change the
value because it doesn't matter.

.  Ed

Other Threads