Skip to content
Snippets Groups Projects
  1. Jun 22, 2024
    • Caio Oliveira's avatar
      glsl: Fix warning related to tg4_offsets in release mode · a0877c13
      Caio Oliveira authored
      
      Compiler can't know that array_size() of the offsets parameter in
      textureGatherOffsets is (at most) 4,  so use a MIN2() to make the limit
      visible.  Just adding an assert() gets ignored in Release builds.
      
      This fixes the following warning in Release compilation:
      
      ```
        ../src/compiler/glsl/glsl_to_nir.cpp: In member function ‘virtual void {anonymous}::nir_visitor::visit(ir_texture*)’:
        ../src/compiler/glsl/glsl_to_nir.cpp:2453:41: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=]
         2453 |                instr->tg4_offsets[i][j] = val;
              |                ~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~
        In file included from ../src/compiler/glsl/glsl_to_nir.h:31,
                         from ../src/compiler/glsl/glsl_to_nir.cpp:29:
        ../src/compiler/nir/nir.h:2470:11: note: at offset 8 into destination object ‘nir_tex_instr::tg4_offsets’ of size 8
         2470 |    int8_t tg4_offsets[4][2];
              |           ^~~~~~~~~~~
        ../src/compiler/glsl/glsl_to_nir.cpp:2453:41: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=]
         2453 |                instr->tg4_offsets[i][j] = val;
              |                ~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~
        ../src/compiler/nir/nir.h:2470:11: note: at offset 9 into destination object ‘nir_tex_instr::tg4_offsets’ of size 8
         2470 |    int8_t tg4_offsets[4][2];
              |           ^~~~~~~~~~~
      ```
      
      This is from: `gcc (GCC) 14.1.1 20240522 (Red Hat 14.1.1-4)`.
      
      Reviewed-by: default avatarJordan Justen <jordan.l.justen@intel.com>
      Part-of: <mesa/mesa!29508>
      a0877c13
  2. Jun 21, 2024
Loading