This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Problem with C166 6.02 and void*

Hello All!

I have a problem with my existing projects since upgrade from 5.04b to 6.02. With 5.04 all code samples below compile and work fine! The new compiler version is much more agressive with some warnings as stated in the release notes.

The following code does generate a warning C98 - pointer to different objects:

unsigned char sigCount[4];
unsigned long sigId[4];

word Function( void )
{
    memset( sigCount, 0, sizeof( sigCount ) );
    memset( sigId, 0, sizeof( sigId ) );
}

The first memset() call generates C98, the second one compiles without errors. If I use a explicit cast (unsigned char*) before sigCount, then the warning disapears. The same problem is with the following code:

typedef struct
{
    unsigned int i;
    unsigned char c;
    ...
} FIDES;

FIDES   FilterDs;
memset( &FilterDs, 0, sizeof(FIDES));


Again, if I make a cast to (FIDES*) before &FilterDs the warning disapears. As far as I have seen, this behaviour is on all functions which receive a void* as a parameter.

A second issue is the following:

unsigned char a, b, c;
...
c = ( a ^ b ) & b;

Here I get the warning C192 : '=': value truncated. If the variable c is unsigned int or I omit the statement '& b', the code compiles. See the following two lines:

c = (unsigned char)( a ^ b ) & b;
c = a ^ b;

Is there anybody out there who can give me the right hint? I think there can be one or more compiler bugs.

Thanks a lot in advance and best regards,

Bernhard Lechleitner

0