https://gcc.gnu.org/bugzilla/show_bug.cgi?id=74762

            Bug ID: 74762
           Summary: Uncaught Wuninitialized case
           Product: gcc
           Version: 7.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: middle-end
          Assignee: unassigned at gcc dot gnu.org
          Reporter: marxin at gcc dot gnu.org
  Target Milestone: ---

$ cat tc2.c
struct tree2;
struct tree_vector2
{
  tree2 *elts[1];
};
struct tree2
{
  struct
  {
    tree_vector2 vector;
  } u;
};
int
const_with_all_bytes_same (tree2 *val)
{
  int i;
  const_with_all_bytes_same ((val->u.vector.elts[i]));

  return 1;
}

$ g++ tc2.c -Wuninitialized -c
(empty)

$ clang++ tc2.c -Wuninitialized -c
clang-3.8: warning: treating 'c' input as 'c++' when in C++ mode, this behavior
is deprecated
tc2.c:17:50: warning: variable 'i' is uninitialized when used here
[-Wuninitialized]
  const_with_all_bytes_same ((val->u.vector.elts[i]));
                                                 ^
tc2.c:16:8: note: initialize the variable 'i' to silence this warning
  int i;
       ^
        = 0
1 warning generated.

The test-case used to be catch in 4.6.x era.

Reply via email to