https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111339
Bug ID: 111339 Summary: bounds-check does not detect nonconforming functions Product: gcc Version: 4.3.0 Status: UNCONFIRMED Severity: enhancement Priority: P3 Component: fortran Assignee: unassigned at gcc dot gnu.org Reporter: mikael at gcc dot gnu.org CC: anlauf at gcc dot gnu.org, dfranke at gcc dot gnu.org, gcc-bugs at gcc dot gnu.org, P.Schaffnit at access dot rwth-aachen.de, tkoenig at gcc dot gnu.org, urbanjost at comcast dot net, vivekrao4 at yahoo dot com Depends on: 31059 Blocks: 27766, 37802 Target Milestone: --- +++ This bug was initially created as a clone of Bug #31059 +++ Gfortran does not report an error if an allocatable array is set to a function of larger size, for example in the code below. program p integer, allocatable :: ivec(:) ivec = [1, 2] ! ivec(:) = func() ! case 1 (already diagnosed) ! ivec(:) = ivec + func() ! case 2 ! ivec(:) = func() + ivec ! case 3 contains function func() integer :: func(3) func = [7, 8, 9] end function func end Uncomment either case 1, case 2 or case 3, and see if the program leads to a runtime error with -fcheck=bounds. Case 1 is diagnosed, but not case 2 and neither case 3. Referenced Bugs: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=27766 [Bug 27766] [meta-bug] -fbounds-check related bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=31059 [Bug 31059] bounds-check does not detect nonconforming assignment arrays https://gcc.gnu.org/bugzilla/show_bug.cgi?id=37802 [Bug 37802] Improve wording for matmul bound checking