public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/109714] New: bogus may be used uninitialized warning
@ 2023-05-03 14:13 david at ixit dot cz
  2023-05-03 18:08 ` [Bug tree-optimization/109714] bogus "may be used uninitialized warning" pinskia at gcc dot gnu.org
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: david at ixit dot cz @ 2023-05-03 14:13 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 109714
           Summary: bogus may be used uninitialized warning
           Product: gcc
           Version: 13.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: david at ixit dot cz
  Target Milestone: ---
              Host: x86_64
            Target: x86_64

Code: https://gitlab.freedesktop.org/mesa/mesa/ main branch
Compiler: 13.0.1 20230315 (experimental) [master r13-6680-ga9ae16db8cb]
Compilation:
```
CC=/usr/lib/gcc-snapshot/bin/gcc CXX=/usr/lib/gcc-snapshot/bin/g++ meson setup
builddir-snapshot -D libdir=lib -D buildtype=release -D build-tests=false -D
enable-glcpp-tests=false -D libunwind=enabled -D glx=dri -D gbm=enabled -D
egl=enabled -D platforms=x11,wayland -D dri3=enabled -D gallium-extra-hud=true
-D gallium-vdpau=disabled -D gallium-omx=disabled -D gallium-va=disabled -D
gallium-xa=disabled -D gallium-nine=false -D gallium-opencl=disabled -D
gallium-rusticl=false -D llvm=enabled -D gallium-drivers=i915,iris,swrast -D
vulkan-drivers= -D video-codecs=h264dec,h264enc,h265dec,h265enc -D
spirv-to-dxil=false -D osmesa=true -D intel-clc=disabled -D
imagination-srv=false
```
```
[1110/1401] Compiling C object
src/gallium/auxiliary/libgallium.a.p/draw_draw_llvm.c.o
In function 'generate_clipmask',
    inlined from 'draw_llvm_generate' at
../src/gallium/auxiliary/draw/draw_llvm.c:2163:24:
../src/gallium/auxiliary/draw/draw_llvm.c:1496:25: warning: 'sum' may be used
uninitialized [-Wmaybe-uninitialized]
 1496 |                   sum = lp_build_fmuladd(builder, planes,
      |                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 1497 |                                          (LLVMValueRef[]){cv_x, cv_y,
cv_z, cv_w}[i], sum);
      |                                         
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../src/gallium/auxiliary/draw/draw_llvm.c: In function 'draw_llvm_generate':
../src/gallium/auxiliary/draw/draw_llvm.c:1343:44: note: 'sum' was declared
here
 1343 |    LLVMValueRef plane1, planes, plane_ptr, sum;
      | 
```

The code (relevant to the sum variable):
```
...
   LLVMValueRef plane1, planes, plane_ptr, sum;
...
            for (int i = 0; i < 4; ++i) {
               indices[2] = lp_build_const_int32(gallivm, i);
               plane_ptr = LLVMBuildGEP2(builder, planes_type, planes_ptr,
indices, 3, "");
               plane1 = LLVMBuildLoad2(builder, vs_elem_type, plane_ptr,
                                       (const char *[]){"plane_x", "plane_y",
"plane_z", "plane_w"}[i]);
               planes = lp_build_broadcast(gallivm, vs_type_llvm, plane1);
               if (i == 0) {
                  sum = LLVMBuildFMul(builder, planes, cv_x, ""); // sum is set
always in first iteration
               } else {
                  // we never get here without having sum already assigned
                  sum = lp_build_fmuladd(builder, planes,
                                         (LLVMValueRef[]){cv_x, cv_y, cv_z,
cv_w}[i], sum);
               }
            }
...
```

Thou the `sum` value is always assigned in first for interation.

I tried do simple test case, but it always works with simple c file.

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2023-05-05 20:19 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-03 14:13 [Bug c/109714] New: bogus may be used uninitialized warning david at ixit dot cz
2023-05-03 18:08 ` [Bug tree-optimization/109714] bogus "may be used uninitialized warning" pinskia at gcc dot gnu.org
2023-05-04  6:07 ` rguenth at gcc dot gnu.org
2023-05-04 18:40 ` david at ixit dot cz
2023-05-04 18:41 ` pinskia at gcc dot gnu.org
2023-05-04 18:47 ` [Bug tree-optimization/109714] mesa/aux/draw_llvm: " pinskia at gcc dot gnu.org
2023-05-05  8:51 ` david at ixit dot cz
2023-05-05 16:20 ` pinskia at gcc dot gnu.org
2023-05-05 16:25 ` pinskia at gcc dot gnu.org
2023-05-05 19:11 ` david at ixit dot cz
2023-05-05 20:19 ` david at ixit dot cz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).