This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
[fortran,patch] Fix PR35682, more wrong array bounds calculation
- From: FX <fxcoudert at gmail dot com>
- To: Fortran List <fortran at gcc dot gnu dot org>, GCC Patches <gcc-patches at gcc dot gnu dot org>
- Date: Tue, 13 May 2008 08:15:15 +0100
- Subject: [fortran,patch] Fix PR35682, more wrong array bounds calculation
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:mime-version:to:message-id:content-type:from:subject:date:x-mailer; bh=X6DElBoG/a3Jpnj0iRb1//12o3oCEzvvdpUImSbFj1k=; b=dxqIuc8SNJLwQBgzv//MuTTseHx3i6Eb7R1dRLdQ+nghMQezK9FU5mSlyzsFQGi7h8YyRfC72Ec6lKXMejX1KuYmWgIY2Qg7p/k9i8m65BUOZhOoCIr7EsVzmyTN61xPQ4wkpttpcmkeeS4bJ9g4aDuqvP+eEl7dqUPwtyqVCps=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:to:message-id:content-type:from:subject:date:x-mailer; b=OLQl6Wucn6moznErobrDhnHz8VRoDiZOAro90FLyuxuD7vPaTqPBvb9CvppVOTd8l4LGhVrVSYqLDpdJ2orQdH6Vuq/jZ3toMb/twMrs8f9n3FHLJmvSYds9tzJhUQRb8ZTRnMrax0s1rIJMNHuFlDY/3pYxhs+FKbLDwkjLNVo=
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?
FX
--
François-Xavier Coudert
http://www.homepages.ucl.ac.uk/~uccafco/
Attachment:
pr35682.ChangeLog
Description: Binary data
Attachment:
pr35682.diff
Description: Binary data