This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

RE: warning: `x' might be used uninitialised in this function


Here is an example which shows the problem.

// cc -O -Wuninitialized -c test3.c -o test3.o

typedef unsigned short u16;
typedef unsigned short __u16;
typedef unsigned int __u32;
typedef unsigned int u32;

typedef	struct {
  u32 vc;  // comment this line out and you get no warnings!
  u32 flags;
  u32 rate;
} command;

static __inline__ __const__ __u16 ___arch__swab16(__u16 y) {
  __asm__("xchgb %b0,%h0" : "=q" (y) : "0" (y));
  return y;
}

extern __inline__ __const__ __u16 __fswab16(__u16 x) {
  return ___arch__swab16( x ) ;
}

int main (void) {
  u16 tx_rate_bits;
  u16 tx_vc_bits;
  command cmd;
  cmd.flags = (__builtin_constant_p((__u16)(tx_vc_bits))
	       ? ((__u16)( (((__u16)(tx_vc_bits) & (__u16)0x00ffU) << 8) |
(((__u16)(tx_vc_bits) & (__u16)0xff00U) >> 8) ))
	       : __fswab16(tx_vc_bits))  ;
  cmd.rate = (__builtin_constant_p((__u16)(tx_rate_bits))
	      ? ((__u16)( (((__u16)(tx_rate_bits) & (__u16)0x00ffU) << 8) |
(((__u16)(tx_rate_bits) & (__u16)0xff00U) >> 8) ))
	      : __fswab16(tx_rate_bits))  ;
  return 0;
}

Giuliano.
-- 
gprocida@madge.com
myxie@debian.org 
 


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]