[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [csmith-dev] csmith error

On Thu, Sep 15, 2011 at 3:45 PM, Yang Chen <chenyang@cs.utah.edu> wrote:
>> C:\cygwin\home\User\csmith\tmp-test\a2p_test02.c(51) : error: C1295:
>> 'xor' only valid on binary types
> I don't quite understand this one. From the attched code, seem your compiler
> complains on something like:
> (uint8_t)a ^ (uint16_t)b
> Although here `a` and `b` are array elements.
> It's an uncommon error message for a compiler.

Nobody has yet explicitly said what the error message *usually* means:
It *usually* means that you're trying to use the ^ operator on
something that's not an integer type. For example:

void give_error(float a, float b) { return a ^ b; }
void give_another_error(int *a, int *b) { return a ^ b; }
void give_a_third_error(struct S a, union U b) { return a ^ b; }

I think Yang is correct that your compiler shouldn't be complaining
here --- or else you attached the wrong test case.  But I could
imagine compiler bugs in this case; your expression is something like
((a || b) ^ c[d][e]).  So I could imagine that your compiler thinks
"oh, (a||b) is a boolean, you can't XOR booleans" (which is just plain
wrong, but it *could* think that).  Or, less plausibly, it could get
confused about the right-hand side and think "you can't XOR anything
with c[d], that's a pointer" (true but irrelevant) or "c[d][e] is a
pointer" (just plain wrong, again).

You might try narrowing it down by figuring out what type your
compiler thinks each subexpression is; does it know that ((g_5[1] !=
g_5[1]) || l_28[2]) is of type "int"?  does it know that l_12[4][0] is
of type "int" (after promotion from "uint16_t")?  and so on.