If compiled with gcc -c -Wconversion the following code produces the warning: test.c:7: warning: conversion to short int from int may alter its value
but if -DNO_WARNING is turned on it doesn't even though it should be same code. cat > test.c <<EOF short mask(short x) { #if NO_WARNING short y = 0x7fff; return x&y; #else return x & (short)0x7fff; #endif } EOF On a side node, I think it would be better to also change the warning to : "conversion from 'int' to 'short int' may alter its value", which i find easier to read. -- Summary: -Wconversion produces wrong warning Product: gcc Version: 4.3.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: Raimund dot Merkert at baesystems dot com GCC target triplet: gcc (GCC) 4.3.0 20071130 (experimental) http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34389