Should the following:

  int foo(int a)
{
  int b;

  if (a != 4)
    __builtin_unreachable();

  if (a == 4)
     b  = 2;

  return b;

give a warning?

The compiler (with -Wsometimes-uninitialized) says that b might not be 
initialized if the second "if" condition is false.

I agree the code is a little silly, but the first "if" condition should be 
enough to convince the compiler that everything's OK.  I'd expect the optimizer 
to even remove all the "if"s and have this function simply return "2" 
unconditionally.

  Michael
_______________________________________________
cfe-users mailing list
cfe-users@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-users

Reply via email to