This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [fortran,patch] Fix PR35682, more wrong array bounds calculation
- From: Tobias Burnus <burnus at net-b dot de>
- To: FX <fxcoudert at gmail dot com>
- Cc: Fortran List <fortran at gcc dot gnu dot org>, GCC Patches <gcc-patches at gcc dot gnu dot org>
- Date: Wed, 14 May 2008 19:21:33 +0200
- Subject: Re: [fortran,patch] Fix PR35682, more wrong array bounds calculation
- References: <FDB4EFC9-F7CB-4983-A1AC-769544A3B393@gmail.com>
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