https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108912
Bug ID: 108912 Summary: A -Wstringop-overflow false positive in aarch64-linux-gnu-gcc 12.2.0 Product: gcc Version: 12.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: wtc at google dot com CC: msebor at gcc dot gnu.org Target Milestone: --- Created attachment 54522 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=54522&action=edit Reduced test case Steps to reproduce: 1. Save the attachment in a file named av1_fwd_txfm2d.c. 2. On a Debian x86_64 GNU/Linux system, install the gcc-aarch64-linux-gnu package: $ sudo apt install gcc-aarch64-linux-gnu 3. Check the compiler version: $ /usr/bin/aarch64-linux-gnu-gcc --version aarch64-linux-gnu-gcc (Debian 12.2.0-3) 12.2.0 Copyright (C) 2022 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 4. Compile the av1_fwd_txfm2d.c file with the following command line: $ /usr/bin/aarch64-linux-gnu-gcc -march=armv8-a -O3 -DNDEBUG -std=c99 -Wall -Wdisabled-optimization -Wextra -Wfloat-conversion -Wformat=2 -Wimplicit-function-declaration -Wlogical-op -Wpointer-arith -Wsign-compare -Wtype-limits -Wuninitialized -Wunused -Wvla -Wstack-usage=100000 -Wshadow -Wundef -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=0 -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -fPIC -o av1_fwd_txfm2d.o -c av1_fwd_txfm2d.c The compiler emits the following warnings: In function ‘set_fwd_txfm_non_scale_range’, inlined from ‘av1_get_fwd_txfm_cfg’ at av1_fwd_txfm2d.c:86:3: av1_fwd_txfm2d.c:64:31: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=] 64 | cfg->stage_range_col[i] = (range_mult2_col[i] + 1) >> 1; | ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ av1_fwd_txfm2d.c: In function ‘av1_get_fwd_txfm_cfg’: av1_fwd_txfm2d.c:23:10: note: at offset 12 into destination object ‘stage_range_col’ of size 12 23 | int8_t stage_range_col[12]; | ^~~~~~~~~~~~~~~ In function ‘set_fwd_txfm_non_scale_range’, inlined from ‘av1_get_fwd_txfm_cfg’ at av1_fwd_txfm2d.c:86:3: av1_fwd_txfm2d.c:64:31: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=] 64 | cfg->stage_range_col[i] = (range_mult2_col[i] + 1) >> 1; | ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ av1_fwd_txfm2d.c: In function ‘av1_get_fwd_txfm_cfg’: av1_fwd_txfm2d.c:23:10: note: at offset 13 into destination object ‘stage_range_col’ of size 12 23 | int8_t stage_range_col[12]; | ^~~~~~~~~~~~~~~ In function ‘set_fwd_txfm_non_scale_range’, inlined from ‘av1_get_fwd_txfm_cfg’ at av1_fwd_txfm2d.c:86:3: av1_fwd_txfm2d.c:72:31: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=] 72 | cfg->stage_range_row[i] = | ~~~~~~~~~~~~~~~~~~~~~~~~^ 73 | (range_mult2_col[cfg->stage_num_col - 1] + range_mult2_row[i] + 1) >> | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 74 | 1; | ~ av1_fwd_txfm2d.c: In function ‘av1_get_fwd_txfm_cfg’: av1_fwd_txfm2d.c:24:10: note: at offset 12 into destination object ‘stage_range_row’ of size 12 24 | int8_t stage_range_row[12]; | ^~~~~~~~~~~~~~~ In function ‘set_fwd_txfm_non_scale_range’, inlined from ‘av1_get_fwd_txfm_cfg’ at av1_fwd_txfm2d.c:86:3: av1_fwd_txfm2d.c:72:31: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=] 72 | cfg->stage_range_row[i] = | ~~~~~~~~~~~~~~~~~~~~~~~~^ 73 | (range_mult2_col[cfg->stage_num_col - 1] + range_mult2_row[i] + 1) >> | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 74 | 1; | ~ av1_fwd_txfm2d.c: In function ‘av1_get_fwd_txfm_cfg’: av1_fwd_txfm2d.c:24:10: note: at offset 13 into destination object ‘stage_range_row’ of size 12 24 | int8_t stage_range_row[12]; | ^~~~~~~~~~~~~~~