[sword-devel] VC compiler warning worth to take a look
DM Smith
dmsmith555 at yahoo.com
Mon Dec 4 09:23:04 MST 2006
Looks like a precedence complaint.
!= is of a higher precedence than & (see:
http://www.cppreference.com/operator_precedence.html)
So it evaluates as:
0xc0 & (utf8[i] != 0x80)
rather than
(0xc0 & utf8[i]) != 0x80
The former always evaluates to 0.
Jari Strand wrote:
> Hi, I was compiling the library in VC++ express 2005 and it gave a warning
> which seems to be worth to take a look.
>
> Here's the output:
>
> swunicod.cpp
> ...\..\..\src\utilfuns\swunicod.cpp(128) : warning C4806: '&' : unsafe
> operation: no value of type 'bool' promoted to type 'int' can equal the
> given constant
>
> And here's the code snippet from that line (128):
>
> for (i = 1; i <= count; i++) {
> if (0xc0 & utf8[i] != 0x80) {
> return 0xffff;
> }
>
>
> I don't know for sure what the warning means so you'll better make your own
> conclusion. :)
>
> I hope this helps.
>
> God bless.
>
>
> Jari.
>
More information about the sword-devel
mailing list