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

            Bug ID: 83382
           Summary: UBSAN tiggers false-positive warning
                    [-Werror=uninitialized]
           Product: gcc
           Version: 8.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: sanitizer
          Assignee: unassigned at gcc dot gnu.org
          Reporter: babokin at gmail dot com
                CC: dodji at gcc dot gnu.org, dvyukov at gcc dot gnu.org,
                    jakub at gcc dot gnu.org, kcc at gcc dot gnu.org, marxin at 
gcc dot gnu.org
  Target Milestone: ---

gcc trunk, rev 255537, x86_64.

Not sure if this is duplicate of #42145 or not, so filing as a separate bug.

The issue goes away if either sanitizer flags removed, "extern" removed from
tf_0_var_14 definition, or "const" removed from the same definition. Though it
points to different variable. So, something fishy is going on here.

You may argue that this analysis is inexact and I shouldn't rely on that, but
it's definitely usability bug, when unrelated things are causing troubles. And
it stops me from using -Werror=uninitialized in test case reduction, where it
really does useful job. 

> cat f.cpp
int tf_0_var_36;
signed char tf_0_var_58;
extern const int tf_0_var_14;
int *tf_0_ptr_8;
void tf_0_foo() {
  tf_0_var_36 >> ((!0 || tf_0_var_58) && (0 ? tf_0_var_14 : *tf_0_ptr_8));
}

> g++  -std=c++11 -fsanitize=undefined -Werror=uninitialized -o 
> ubsan_gcc_o2_func.o -c f.cpp
f.cpp: In function ‘void tf_0_foo()’:
f.cpp:6:72: error: ‘tf_0_ptr_8.1’ is used uninitialized in this function
[-Werror=uninitialized]
   tf_0_var_36 >> ((!0 || tf_0_var_58) && (0 ? tf_0_var_14 : *tf_0_ptr_8));
                                                                        ^
cc1plus: some warnings being treated as errors

Reply via email to