Bug 101827 - Wrong stringop-overflow warning
Summary: Wrong stringop-overflow warning
Status: UNCONFIRMED
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 10.1.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: diagnostic
Depends on:
Blocks: Wstringop-overflow
  Show dependency treegraph
 
Reported: 2021-08-09 09:52 UTC by Ignacio Fernández Galván
Modified: 2022-10-23 00:22 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ignacio Fernández Galván 2021-08-09 09:52:23 UTC
When trying to compile OpenMolcas with gcc 10.1 and link-time optimization I get:

../src/slapaf_util/outofplane_list.f: In function ‘outofplane_list’:                                
../src/slapaf_util/outofplane_list.f:524: error: writing 1 byte into a region of size 0 [-Werror=stringop-overflow=]
  524 |                      Lbls(3)(iE3+1:iE3+1)='('                                               
      |                                                                                             
../src/slapaf_util/outofplane_list.f:45:32: note: at offset 0 to object ‘lbls’ with size 40 declared here
   45 |       Character*(LENIN4) Lbls(4)                                                            
      |                                ^                                                            
[...]
lto1: all warnings being treated as errors                                                          
lto-wrapper: fatal error: /usr/bin/gfortran returned 1 exit status                                  


How is "Lbls(3)(iE3+1:iE3+1)" a region of size 0? Similar constructs elsewhere don't raise the flag. Does the compiler believe "iE3+1" is beyond the length of the string? But then it says nothing without -flto.
Comment 1 Richard Biener 2021-08-09 12:53:17 UTC
Can you attach a TU where this issue shows?
Comment 2 Ignacio Fernández Galván 2021-08-09 14:18:44 UTC
What's a TU? I didn't succeed (but didn't try to hard) in creating a minimal test case. But this reproduces the problem:

$ git clone -b ipo https://gitlab.com/Molcas/OpenMolcas.git
$ cd OpenMolcas
$ git submodule update --init External/lapack

# (comment out the line in src/gateway_util/Symmetry_Info.f90
#  that refers to this report, i.e. search for 101827.
#  But note that the "ipo" branch is in development and will change.)

$ mkdir build
$ cd build
$ cmake -D BUILD_SHARED_LIBS=ON -D BIGOT=ON ..
$ make
[...]
[ 65%] Linking Fortran shared library lib/libmolcas.so
In function ‘chtab’,
    inlined from ‘__symmetry_info_MOD_symmetry_info_setup.part.0’ at /OpenMolcas/src/gateway_util/Symmetry_Info.f90:335:0:
/OpenMolcas/src/gateway_util/Symmetry_Info.f90:655: error: writing 1 byte into a region of size 0 [-Werror=stringop-overflow=]
  655 |                 lIrrep(iIrrep-1)(i1:i1)='u'
      | 
/OpenMolcas/src/gateway_util/Symmetry_Info.f90: In function ‘__symmetry_info_MOD_symmetry_info_setup.part.0’:
/OpenMolcas/src/gateway_util/Symmetry_Info.f90:17:60: note: at offset 0 to object ‘lirrep’ with size 24 declared here
   17 | Public :: nIrrep, iOper, iChTbl, iChCar, Mul, iChBas, lIrrep, lBsFnc, SymLab, iSkip, &
      |                                                            ^
In function ‘chtab’,
    inlined from ‘__symmetry_info_MOD_symmetry_info_setup.part.0’ at /OpenMolcas/src/gateway_util/Symmetry_Info.f90:335:0:
/OpenMolcas/src/gateway_util/Symmetry_Info.f90:653: error: writing 1 byte into a region of size 0 [-Werror=stringop-overflow=]
  653 |                lIrrep(iIrrep-1)(i1:i1)='g'
      | 
/OpenMolcas/src/gateway_util/Symmetry_Info.f90: In function ‘__symmetry_info_MOD_symmetry_info_setup.part.0’:
/OpenMolcas/src/gateway_util/Symmetry_Info.f90:17:60: note: at offset 0 to object ‘lirrep’ with size 24 declared here
   17 | Public :: nIrrep, iOper, iChTbl, iChCar, Mul, iChBas, lIrrep, lBsFnc, SymLab, iSkip, &
      |                                                            ^
lto1: all warnings being treated as errors
lto-wrapper: fatal error: /usr/bin/gfortran returned 1 exit status