[Bug fortran/71027] -fsanitize=address catches out of bounds access on assumed size array only with -O0
dominiq at lps dot ens.fr
gcc-bugzilla@gcc.gnu.org
Mon May 9 18:33:00 GMT 2016
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71027
Dominique d'Humieres <dominiq at lps dot ens.fr> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |WAITING
Last reconfirmed| |2016-05-09
Ever confirmed|0 |1
--- Comment #1 from Dominique d'Humieres <dominiq at lps dot ens.fr> ---
IMO your expectation is invalid:
[Book15] f90/bug% gfc pr71027.f90 -Og -fdump-tree-optimized
[Book15] f90/bug% cat pr71027.f90.211t.optimized
;; Function main (main, funcdef_no=2, decl_uid=3429, cgraph_uid=2,
symbol_order=2) (executed once)
__attribute__((externally_visible))
main (integer(kind=4) argc, character(kind=1) * * argv)
{
static integer(kind=4) options.0[9] = {68, 1023, 0, 0, 1, 1, 0, 0, 31};
<bb 2>:
_gfortran_set_args (argc_2(D), argv_3(D));
_gfortran_set_options (9, &options.0[0]);
return 0;
}
i.e., the subroutine sub is optimized away. If you do something such as
subroutine sub(vv)
dimension vv(*)
x=vv(20) ! out of bounds access
vv(1)=x
end subroutine
then -fsanitize=address catches the invalid address.
More information about the Gcc-bugs
mailing list