If I have a header file (simplified sample) that contains:
inline static void *
ollistitem(char *fname, int item, void *data)
{
if (fname != 0 && item)
return data;
else return 0;
}
Which is used in different source files with item passed as constant, compiler complains that code is unreachable because part of function is never used in one translation unit (but may be used in another translation unit).
Here is an example:
#include <stdio.h>
#include "foo.h"
void* olfirst(void* data);
void*
olfirst(void* data)
{
return( ollistitem( "foo", 0, data) );
}
In this translation unit, index is passed as 0 which results to "else return 0;" which can be deduced at compile time.
Another translation unit may use the same inline function with a different index value resulting to true condition.
This annoying because using -W0 may hide other precious warnings.
Christian