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

Martin Sebor <msebor at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |diagnostic
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2019-02-12
                 CC|                            |msebor at gcc dot gnu.org
          Component|c                           |middle-end
             Blocks|                            |24639
     Ever confirmed|0                           |1

--- Comment #1 from Martin Sebor <msebor at gcc dot gnu.org> ---
You're right that the sanitizers tend to interfere with GCC middle-end warnings
(there are a number of reports about this in Bugzilla -- see for example bug
82076 and the comments there).  Usually the complaints are about the
instrumentation causing false positives, but as the simplified test case below
shows, it can cause false negatives as well.  It may be possible to improve
things but in general the consensus seems to be that given the current
architecture it's unavoidable.  Documenting this in the manual as you suggest
in the upstream discussion sounds like a good idea.

I'm going to confirm this until someone has looked into in more detail how
feasible avoiding the false negative might be in this instance. 

$ cat pr89284.c && gcc -O2 -S -Wall -Wno-unused -fsanitize=undefined,address
pr89284.c
struct A
{
  _Bool a;
  int i;
};

void f (void)
{
  struct A a;

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

void g (void)
{
  struct A a;

  if (a.a) {   // missing -Wuninitialized
    struct A b = a;
  }
}
pr89284.c: In function ā€˜f’:
pr89284.c:11:8: warning: ā€˜a.i’ is used uninitialized in this function
[-Wuninitialized]
   11 |   if (a.i) {   // -Wuninitialized (good)
      |       ~^~


Referenced Bugs:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=24639
[Bug 24639] [meta-bug] bug to track all Wuninitialized issues

Reply via email to