[Bug middle-end/93100] New: gcc -fsanitize=address inhibits -Wuninitialized

bhalevy at gmail dot com gcc-bugzilla@gcc.gnu.org
Mon Dec 30 10:31:00 GMT 2019


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

            Bug ID: 93100
           Summary: gcc -fsanitize=address inhibits -Wuninitialized
           Product: gcc
           Version: 9.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: middle-end
          Assignee: unassigned at gcc dot gnu.org
          Reporter: bhalevy at gmail dot com
  Target Milestone: ---

Similar to -fsanitize=undefined in
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89284, -fsanitize=address also
inhibits -Wuninitialized.

$ cat prog.cc
struct A
{
  bool a;
  int i;
};

void f (void)
{
  struct A a;

  if (a.i) {   // expecting -Wuninitialized wearning
    struct A b = a;
  }
}

void g (void)
{
  struct A a;

  if (a.a) {   // expecting -Wuninitialized wearning
    struct A b = a;
  }
}

$ gcc -O0 -S -Wuninitialized -Wno-unused prog.cc --sanitize=address
<no output>

$ gcc -O0 -S -Wuninitialized -Wno-unused prog.cc
prog.cc: In function ‘void f()’:
prog.cc:11:9: warning: ‘a.A::i’ is used uninitialized in this function
[-Wuninitialized]
   11 |   if (a.i) {   // expecting -Wuninitialized wearning
      |       ~~^
prog.cc:12:14: warning: ‘a’ may be used uninitialized in this function
[-Wmaybe-uninitialized]
   12 |     struct A b = a;
      |              ^
prog.cc: In function ‘void g()’:
prog.cc:20:9: warning: ‘a.A::a’ is used uninitialized in this function
[-Wuninitialized]
   20 |   if (a.a) {   // expecting -Wuninitialized wearning
      |       ~~^
prog.cc:21:14: warning: ‘a’ may be used uninitialized in this function
[-Wmaybe-uninitialized]
   21 |     struct A b = a;
      |              ^


More information about the Gcc-bugs mailing list