This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [fortran,patch] Fix PR35682, more wrong array bounds calculation


FX wrote:
Attached patch fix PR 35682 and all its symptoms: the basic flaw in bounds calculation is in gfc_conv_loop_setup(), where a TRUNC_DIV_EXPR is used instead of a FLOOR_DIV_EXPR. This fixes all the wrong-code symptoms of the bug, but still leave one issue with -fbounds-check: we sometimes emit a message in gfc_conv_ss_startstride() that section sizes don't match because one is 0 and one is -1 (or any other negative number). This is wrong, as negative sizes don't exist, only zero-sized sections, so we take the appropriate step: size = MAX(size, 0). We also do the the same thing just after the fix in gfc_conv_loop_setup(), and we're done.

Regtested on x86_64-linux (both -m32 and -m64), comes with a duplicated testcase (once with -fbounds-check and once without) expanded from the PR testcase. OK to commit?

If MAX is only needed for -fbounds-check, how about adding it only when the bounds are checked?


OK with or without that change.

Tobias


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]